In This Chapter
Reusing common attributes and operations
Defining generalization and specialization
Providing steps to show generalization
Adding discriminators to inheritance hierarchies
Weighing the pros and cons of multiple inheritance
It’s natural to classify objects in categories and to organize categories into subcategories. If you look for a place to live, you find yourself categorizing a dwelling unit as a house, apartment, townhouse, condominium, mansion, and so on. Houses can, in turn, be further organized by styles such as ranch, split-level, colonial, and saltbox. UML provides you with notation to capture these types of classifications—also known as generalization and specialization—and make use of them as a modeler and a programmer. This chapter covers generalization—and how it leads to inheritance. (Specifically, subclasses that inherit the attributes and operations of a superclass. For more on superclasses and subclasses read on.) We show you the UML notation for inheritance and how to take advantage of it.
Some of us object-oriented developers will go to great lengths to save ourselves a little work. When we can model something once and reuse it, we’re interested. If we can write a method (the program code for an operation) for a class only once and use it many times, then sign us up for higher productivity. If you want to save yourself time by specifying attributes and operations once and then reusing them many times, read on.