Section 2.5. Abstract Classes


2.5. Abstract Classes

An abstract class is typically a class that provides an operation signature, but no implementation; however, you can have an abstract class that has no operations at all. An abstract class is useful for identifying common functionality across several types of objects. For example, you can have an abstract class named Movable. A Movable object has a current position and the ability to move somewhere else using an operation named move( ). There can be several specializations of this abstract classa Car, a Grasshopper, and a Person, each of which provides a different implementation of move( ). Because the base class Movable doesn't have an implementation for move( ), the class is said to be abstract.

You show a class is abstract by writing its name in italics. Show each abstract operation in italics as well. Figure 2-20 is an example of the abstract class Movable.

Figure 2-20. Abstract class


An abstract class can't be instantiated; it must be subclassed and then a subclass which does provide the operation implementation can be instantiated. See "Relationships" for more information on subclasses.




UML 2.0 in a Nutshell
UML 2.0 in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596007957
EAN: 2147483647
Year: 2005
Pages: 132

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