How should overruling of overloaded functions work?
Kristian
kjkilpi at gmail.com
Sun Aug 20 08:07:18 PDT 2006
On Sun, 20 Aug 2006 14:54:29 +0300, Søren J. Løvborg <web at kwi.dk> wrote:
> This is the old problem of modifying the base class, while having the
> subclass continue to work as it should. It manifests itself in many ways.
>
> The only way one can be sure to avoid this problem, is to never extend a
> class that one does not control -- i.e. classes defined in libraries etc.
>
> If this rule is followed, there's indeed no reason for the current (C++
> like) hiding of overloaded functions.
>
> See for instance, "Why extends is evil" at JavaWorld, discussing the
> "fragile base-class" problem.
> http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
>
> Quote:
>> I once attended a Java user group meeting where James Gosling
>> (Java's inventor) was the featured speaker. During the memorable
>> Q&A session, someone asked him: "If you could do Java over again,
>> what would you change?" "I'd leave out classes," he replied.
>
> It's a controversial topic. :-)
>
> Søren J. Løvborg
> web at kwi.dk
>
Thanks for the link to the article, it was interesting. There were good
points, although inheritance was designed so that you can re-use the old
code, of course. Inheritance is a good thing, but it can also be a bad
thing. I guess there are two sides in every programming style, rules, etc.
More information about the Digitalmars-d
mailing list