Re: domains aren't subtypes, right?

From: D Guntermann <guntermann_at_hotmail.com>
Date: Fri, 23 May 2003 15:46:48 GMT
Message-ID: <HFCJu1.H48_at_news.boeing.com>


Shouldn't the string type be considered as possible internal representation, decoupled from the type and intended inherent behavior of a city type?

By having "city" inherting the properties and behavior of the string, one would conceivably lose the ability to differentiate between some arbitrary string and a city unless all the operators on the string were all overloaded. This might be the effects some want to achieve, but I can also see value in having a city type only having a discrete set of operators that are defined to operate against another defined discrete set of types. One could alway invoke a selector invocator to expose the internal representation as a string when needed, right?

I personally believe that inheritence in this case is not the right approach, but rather using composition would serve to more crisply define a city type. Nonetheless, the type designer would make the ultimate decision. It might be easier in the short run to have a city type act like a string; but in the long run, having a system differentiate a "city" by not allowing comparands and operands with other types such as "state" or "name" would be extremely beneficial.

Regards,

Daniel Guntermann
"Marshall Spight" <mspight_at_dnai.com> wrote in message news:DGhza.951082$F1.115813_at_sccrnsc04...
> Hi,
>
> 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. Then you could decide what operators/functions
> this new type would "get" (inherit?) from its originating type. For
example,
> you might want to compare city values for equality, or for lexical order,
> but you wouldn't meaningfully want to concatenate city values, even
> though city comes from string and string has a concat operator.
>
> Sometimes I hear this called a "domain" but that word seems heavily
> overloaded.
>
> So what is the relationship of the city type to the string type? It's
> not a subtype. Could it be a supertype? Some other kind of relationship
> entirely?
>
>
> Marshall
>
>
>
Received on Fri May 23 2003 - 17:46:48 CEST

Original text of this message