UML
The UML puts some notations to out software model. Usually, a single class is represented with a box that is divided into three parts:
- The upper section contains the class name.
- The middle section has lists attributes of the class.
- The lower section lists methods of the class.
The members of the class in the middle and lower sections can be prefixed with a symbol to indicate the access level or visibility:
- +: a public member
- -: a private member
- #: a protected member
We can tell the relationships between classes by using various styles of connecting lines and arrowheads:
- Association: A simple dependency between two classes where neither owns the other, indicated as a solid line. Association can be directional, shown with an open arrowhead (">").
- Aggregation: A has-a, or whole/part, relationship where neither class owns the other, indicated as a solid line with a hollow diamond.
- Composition: A has-a relationship where the lifetime of the part is managed by the whole. This is shown as a solid line with a filled diamond.
- Generalization: A subclass relationship between classes, represented as a hollow triangle arrowhead.
Each side of a relationship can also be annotated to define its multiplicity. This lets us specify whether the relationship is one to one, one to many, or many to many:
- 0..1 = zero or one instance
- 1 = one instance
- 0..* = zero or more instances
- 1..* = one or more instances