Java - Help Understanding Advice From Learning Java Third Edition

Hi,
The following piece of text comes from the first chapter of this book,
which starts to talk about classes. I feel that it's important for me to
grasp what it's talking about, but I don't understand what it's trying to
tell me. Can anyone say it a different way and possibly help me understand
what it's driving at?

Specialize objects only when you have to—use composition instead of
inheritance . When you use an object in its existing form, as a piece of a
new object,
you are composing objects. When you change or refine the behavior of an
object (by subclassing ), you are using inheritance . You should try to
reuse objects
by composition rather than inheritance whenever possible because when you
compose objects, you are taking full advantage of existing tools.
Inheritance
involves breaking down the barrier of an object and should be done only
when there's a real advantage. Ask yourself if you really need to inherit
the whole
public interface of an object (do you want to be a "kind" of that object)
or whether you can just delegate certain jobs to the object and use it by
composition.

I feel almost like they are saying that you should import the code from the
objects you want to use into your program and make entirely new classes
that use the imported ones. Am I on the right track?

Thanks.

Jim

James D Homme, Usability Engineering, Highmark Inc.,
james.homme@xxxxxxxxxxxx, 412-544-1810

"it is only possible to live happily ever after on a day-to-day basis." --
Margaret Bonnano

Highmark internal only: For usability and accessibility:
http://highwire.highmark.com/sites/iwov/hwt093/

Other related posts: