Sams Teach Yourself C++ in 21 Days

(singke) #1
Object-Oriented Analysis and Design 341

11
The UML is a rich modeling language, and you can capture any number of relationships.
The principal relationships captured in analysis, however, are as follows:


  • Generalization (or specialization)

  • Containment

  • Association
    Generalization Generalization is often equated with “inheritance,” but a sharp and
    meaningful distinction exists between the two. Generalization describes the relationship;
    inheritance is the programming implementation of generalization. Inheritance is how
    generalization is manifested in code. The other side of the generalization coin is special-
    ization. A cat is a specialized form of animal; animal is a generalized concept that unifies
    cat and dog.
    Specialization implies that the derived object is asubtype of the base object. Thus, a
    checking account is abank account. The relationship is symmetrical: Bank account gen-
    eralizesthe common behavior and attributes of checking and savings accounts.
    During domain analysis, you should seek to capture these relationships as they exist in
    the real world.


FIGURE11.5
Specialization. Bank Account


Checking Account Savings Account

Generalization

Domain object

Again, it is important to note that what is being shown at this time are the
relationships among classes in the requirements domain. Later, you might
decide to have a CheckingAccountobject in your design as well as a
BankAccountobject, and you can implement this relationship using inheri-
tance; but these are design-time decisions. At analysis time, all you are docu-
menting is your understanding of these requirements domain.

NOTE

Free download pdf