---
title: "Dependency, association, aggregation, realization"
subject: "Object Oriented Analysis and Design"
chapter: 2
key: "semester_6/object_oriented_analysis_and_design:four-primary-class-relations"
source: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/four-primary-class-relations
site: BCT Engineering
---

# Dependency, association, aggregation, realization

Object Oriented Analysis and Design · Chapter 2: Object Oriented Analysis

- Asked in: 2070 Bhadra, 8 marks
- Video: [UML Tutorial:  Association, Aggregation, Composition, Dependency, Generalization, and Realization](https://www.youtube.com/watch?v=6cQs1JkUrY0) — Prototype Project
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/four-primary-class-relations
- Whole chapter: https://www.bctengineer.com/md/semester_6/object_oriented_analysis_and_design/chapter-2

## Question

Explain four primary relations between classes; dependency, association, aggregation, and realization, with their corresponding notations.

## 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).

## Answer

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>>`.
```text
 +---------+  - - - - - - ->  +---------+
 | 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.
```text
 +---------+ 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.
```text
 +------------+ <>-------- +---------+   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.
```text
 +------------+
 | <<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 |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Dependency is best described as:
   A. An 'is-a' relationship
   B. A permanent whole-part relationship
   C. A solid line with multiplicity
   D. A temporary 'uses' relationship, drawn as a dashed arrow
   Answer: D. Dependency is temporary, e.g. a parameter, shown dashed. (Key point: Dependency)

2. Which is an example of composition?
   A. Building has Rooms
   B. Department has Teachers
   C. Printer uses Report
   D. Teacher teaches Course
   Answer: A. In composition the part cannot live without the whole; the diamond is filled. (Key point: Aggregation vs composition)

3. Association is drawn as:
   A. A filled diamond
   B. A solid line, optionally with multiplicity and role names
   C. A dashed arrow
   D. A hollow triangle
   Answer: B. Association is a structural solid-line link. (Key point: Association notation)

4. Realization connects:
   A. An actor to a use case
   B. A class to the interface it implements, dashed with hollow triangle
   C. Two classes sharing an attribute
   D. A whole to its part
   Answer: B. The class guarantees the operations declared by the interface. (Key point: Realization)

## Related in Object Oriented Analysis and Design

- [Four class relationships from figure](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aclass-relationships-from-figure) — Object Oriented Analysis and Design, chapter 2

## Related in other subjects

- [Primary and secondary energy at 45% exceedance](https://www.bctengineer.com/question.md?key=semester_6%2Fhydro_power%3Aprimary-secondary-energy-45pct) — Hydro Power, chapter 3
- [Power duration curve and primary/secondary energy](https://www.bctengineer.com/question.md?key=semester_6%2Fhydro_power%3Apower-duration-curve-energy) — Hydro Power, chapter 3
- [Capacitor size, four-node 11 kV feeder](https://www.bctengineer.com/question.md?key=semester_8%2Ftransmission_and_distribution_system_design%3Acapacitor-size-four-node-feeder) — Transmission and Distribution System Design, chapter 7, asked 5×
