The Artima Developer Community
Sponsored Link

Composition Versus Inheritance

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:

Composition Versus Inheritance

Posted by Bruce Blackshaw on 18 Oct 1998, 10:46 AM

Bill,

I feel this is a timely & useful article. Programmers new to OO (which includes
a lot of Java programmers) often tend to go overboard when they
discover inheritance & virtual functions.

Unless you clearly have a "is-a" relationship, composition should be
one of the first options considered in OO design(IMO).

Code maintenance can be an absolute nightmare if a programmer has used
complicated inheritance hierarchies when composition may well have
been more appropriate in places.

All this highlights the importance of a good OO design process. The
more upfront design, the more maintainable the result. As an aside,
I've recently been using UML's object sequence diagrams in the
design process & have been suprised at how useful the technique has been.

Bruce Blackshaw
London, UK



Replies:

Sponsored Links



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