BaseClass |
---|
- private field : Type |
| - private method (Args) : ReturnType
IS-A (Inheritance): Arrow from a box to the base class.
OWNS-A (Ownership): Black diamond from the owning class with an arrow to the owned class.
A
owns B
, then when A
is destroyed, so is B
.B
does not have an independent existence. B
exists for the sole purpose of A
.Car
OWNS-A Motor
. When a car is destroyed, so is the motor. RAII is also a good example of following OWNS-A.HAS-A (Shallow Membership): Arrow is same as OWNS-A, but the diamond is white.
A
has B
, then when A
is destroyed, nothing happens to class B
.B
is an independent existence.Pond
HAS-A Duck
. When a pond is destroyed, the ducks are still alive. They just fly away.Single Responsibility Principle: A class should only have one reason to change.
Open-Closed Principle: Classes, modules, functions, etc. should be open for extension but closed for modification.
We want low coupling, high cohesion.
Coupling: Strength of interdependence of modules.
Cohesion: Closeness of relations between modules.
<utility>
library)