OO Design and UML

Created

OO Design

Identify when objects in a problem definition are related by inheritance; when can you say "every A is B"?

  • B could be the base class (superclass, parent)
  • A would be the derived class (subclass, child)
  • class A inherits from class B.

Identify when objects are related by composition; when can you say "every A has a B"?

  • A would be the containing class
  • B would be the contained class
  • class A is partially composed from class B.

Aggregation is composition, but for collections of objects of another class type.

UML

Unified Modeling Language helps us visualize relationships.

  • class names go in rectangles
  • directed arrow goes from derived class (A) to base class (B)
    • class A -- IS-A --> class B
  • diamond at containing class (A) goes to the contained class (B).
    • class A <>-- HAS-A -- class B

UML Design of a vet clinic.

Alternative UML design.

A more complex UML diagram would have class name, data members, and method functions in each box.


UML is much more than just class diagrams.