The Artima Developer Community
Sponsored Link

Very well said

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Very well said

Posted by Bill Venners on 25 Oct 1998, 7:24 PM

> First, the shown method of substituting composition for inheritance is the standard way VB does inheritance (except,of course an 'implements' clause which forces the subclass to have all methods provided by the parent.
> They call it 'inheritance by delegation' . I've seen developers snorting at this 'inferior' method of doing things... including me. :-)

>
> More on the inheritance/delegation talk :

> I was trying to answer the questions posed by the author
> and came up with a schema
> (at www.cs.cmu.edu/~vinu/temp/relations.html ) for the employee-person relationship.

> Extending the same argument for the employee -manager- person situation, there seems to be a standard classification problem here ( ref: UML distilled,by Fowler & Scott or UML, by Lee and Tepfenhart).

> By definition, a class represents the behaviour an object will exhibit during its lifetime. And if a behaviour set is not for the entire lifetime, then we cannot make a subclass of that.
> ( like the employee -person ) .
> Also, this 'impermanent' or modal behaviour of objects is dependent on the problem domain.

> I will illustrate this with an example.
> An example would be a Shape (superclass), and Circle (subclass).
> This may seem good and nice in particular problem domains, like drawing these shapes, for eg.

> Now, if we start allowing the user to modify these shapes ?
> for instance, the user clicks on a circle and deforms it to form an unidentifiable shape. So, is it still an object of class circle ?

> In such a situation as this, we now have the 'circle'ness of the object an impermanent 'mode'. Then, we have to take up different
> schemes like composition.
> in this example, we'll have a 'drawing object' which will have a 'shape' associated with it, and the shape can change from a circle to something else, and we are still nice and pretty.

> Any feedback on this is welcome
> Thanks.

All I can offer in feedback is that I agree with all of this
and that I think you stated it very well, including the
little class diagram on the web page you referenced.

bv




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us