When to Use Inheritance


Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 7.  Inheritance

Inheritance is a great tool when used properly, therefore, you need to understand when to use it. The thought process is to look at all the objects you are designing collectively and identify both the attributes and behaviors that are common between the objects as well as those that differentiate the individual objects.

Attributes and behaviors that are common between objects are called generalizations, and they belong in common super classes. In this case we moved the functionality common to both the Pinto and Porsche objects to the Car object. Attributes and behaviors that differentiate objects are called specializations, and they belong in different subclasses.


    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net