- 2070 Bhadra · 8 marks
Dependency, association, aggregation, realization
Short answer
Dependency is a temporary using relationship (dashed arrow). Association is a structural link between objects (solid line). Aggregation is a whole-part relationship where parts live independently (hollow diamond); composition uses a filled diamond. Realization connects an interface to its implementing class (dashed line with hollow triangle).
Explain four primary relations between classes; dependency, association, aggregation, and realization, with their corresponding notations.
Relationships connect classes so that they can collaborate. UML defines four primary relationships between classes.
1. Dependency
A using relationship: a change in one class (the supplier) may affect another (the client). It is temporary, e.g. a class uses another as a method parameter, local variable or return type.
Notation: dashed line with open arrowhead pointing to the supplier, optionally with a stereotype <<use>>.
+---------+ - - - - - - -> +---------+
| Printer | | Report |
+---------+ +---------+
Printer.print(Report r)
2. Association
A structural relationship: objects of one class are linked to objects of another for a longer time. It can have a name, role names, multiplicity and navigation arrow. Notation: solid line.
+---------+ 1 0..* +---------+
| Teacher |------------| Course |
+---------+ teaches +---------+
3. Aggregation (and composition)
A special association for a whole-part ("has-a") relationship. In aggregation the part can live independently of the whole (a Department has Teachers). In composition the part's life depends on the whole (a Building has Rooms). Notation: aggregation = hollow diamond at the whole; composition = filled diamond.
+------------+ <>-------- +---------+ aggregation
| Department | | Teacher |
+------------+ +---------+
+------------+ <#>------- +---------+ composition
| Building | | Room |
+------------+ +---------+
4. Realization
A relationship between a specification (interface) and the class that carries it out. The class guarantees to provide the operations declared by the interface. Notation: dashed line with a hollow triangle pointing to the interface.
+------------+
| <<interface>>
| Payment |
+------------+
^
: (dashed, hollow triangle)
+------------+
| CardPayment|
+------------+
(Generalization, the "is-a" relation, is the fifth common relationship and is drawn as a solid line with a hollow triangle.)
| Relation | Line | Meaning |
|---|---|---|
| Dependency | dashed arrow | uses temporarily |
| Association | solid line | knows / linked to |
| Aggregation | line with diamond | whole-part |
| Realization | dashed + hollow triangle | implements interface |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Four class relationships from figure · Object Oriented Analysis and Design, chapter 2
- Primary and secondary energy at 45% exceedance · Hydro Power, chapter 3
- Power duration curve and primary/secondary energy · Hydro Power, chapter 3
- Capacitor size, four-node 11 kV feeder · Transmission and Distribution System Design, chapter 7 · asked 5×
All Object Oriented Analysis and Design chapter 2 questions →