RE: Virtual aka overridable
"Michael S. Muegel" <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.wxnet |
|---|---|
| Message-ID | <[email protected]> |
Bryan wrote:
> However, you can still override any method in C# by using the 'new'
keyword:
>
> public new void MyOverride() { ... }
But I believe this breaks polymorphism. If a parent class references an
instance of the child class, it will not have access to the shadowed member
and will use the parent version instead.
> 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.
I guess we have to agree to disagree on this. 95% of the time when I am
overriding I am calling the base member in addition to doing some other
internal housekeeping or task. I am not changing implementation details as
much as adding to them. IMHO anyone stopping me from doing this is
forgetting the whole OO point. So I think Java has it right. And overriding
is an advanced feature that newbies stay away from.
I know when I was coming up to speed on SWF last year people really detested
how many members were non-virtual.
-Mike
--
Michael S. Muegel
Dallas, TX
-------------------------------------------------------
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