Re: domains aren't subtypes, right?

From: Mikito Harakiri <mikharakiri_at_ywho.com>
Date: Fri, 23 May 2003 09:46:00 -0700
Message-ID: <Ilsza.4$Kj7.85_at_news.oracle.com>


"Marshall Spight" <mspight_at_dnai.com> wrote in message news:DGhza.951082$F1.115813_at_sccrnsc04...
> So, I sometimes hear this idea that you could create a new type from
> an existing type. One example I've heard is that you could declare
> a "city" type (as part of an address) that was in some way derived
> from the string type.

I would inherit City from Location and define getName method. Err, no, I would better derive a City from Village. Now my program is smart, it can tell if an address points to a City or Village location! Wait a minute, can I just query population instead?

Seriously, I havent seen more contraversial concept than inheritance. Look at those endless LSP debates, for example. I would give you a pass (couldn't resist imitation;-) inheriting City from String if you show me a heterogeneous list of String with some Strings being Cities. You also have to justify the need to iterate this list and invoke some method for each list element. And this method must have different implementation for the City and String class. Received on Fri May 23 2003 - 18:46:00 CEST

Original text of this message