Inheritance & Generalization

If you know something about a category of things, you automatically know some things you can transfer to other categories.

If you know something is an animal, you take for granted that it eats, sleeps, has a way of being born, has a way of getting from one place to another... But imagine that mammals, amphibians and reptiles are all animals. Also cows, dogs, cats... are grouped in category mammals. Object-orientation refers to this as inheritance.

class-hierarchy An inheritance hierarchy in the animal kingdom

note.GIF (411 bytes)One class (the child class or subclass) can inherit attributes and operations from another (the parent class or superclass). The parent class is more general then the child class.
In generalization, a child is substitutable for a parent. That is, anywhere the parent appears, the child may appear. The reverse isn't true, however.

note.GIF (411 bytes)In UML inheritance is represented with a line that connects the parent to a child class, and on the parent's side you put an open triangle.

If we look from the association's side, the inheritance stands for is a kind of association.

What should analysts do to discover inheritance?
The analyst has to realize that the attributes and operations of one class are general and apply to perhaps several other classes - which may add attributes and operations of their own. Another possibility is that the analyst notes that two or more classes have a number of common attributes and operations.

note.GIF (411 bytes)Classes that provide no objects are said to be abstract classes. You indicate an abstract class by writing its name in italics.

A class can inherit attributes and operations from another class. The inheriting class is the child of the parent class it inherits from. Abstract classes are intended only as bases for inheritance and provide no objects of their own.