RE: Virtual aka overridable

"Bryan Bulten" <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
Hola,

> OK. So that is the logic. Just looking at Window.cs it is totally out of
> sync virtual-wise with window.h (where Cursor() is based). I will fix
> later.  I'm surprised wx-c-gen.pl does not take care of this.

wx-c-gen.pl was written before I had come up with a solution for
overriding virtual methods from C#.  Haven't updated it since...

> Does everyone agree that something can be virtual in wx.NET and not in
> wxWidgets? They do not really *have* to sync up: if the wx.Widgets guys
> did not feel something should be virtual but we do it can be out of sync.

They don't have to sync.  However, you can still override any method in C#
by using the 'new' keyword:

    public new void MyOverride() { ... }

> One of my biggest beefs with C# and VB.NET is members are not overridable
> by default (and this really is just a language construct). Maybe I am
still an
> OO newbie but this just does not make much sense. People forget (in
> general)
> to add virtual (C#) / overridable (VB.NET) and so you get very closed
> classes.

That is true.  However, I find that overall, this is a good thing.  In
Java, members are virtual by default.  Sometimes it's difficult to tell
what you should and shouldn't override.  By explicitly specifying virtual,
C# programmers can make their code a little more bullet proof, and explicit.

At one extreme, it's possible to unintentionally override a method, when one
is not familiar with the base class.

The same thing goes for C#'s 'ref' and 'out' keywords.  They help to remove
careless programming errors.


-- 
Bryan Bulten
http://bulten.ca/
http://wxnet.sourceforge.net/



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.