Skip to content

Object Relationships

Objects in a system don’t exist in isolation — they relate to each other. Understanding object relationships is crucial for designing flexible, maintainable systems.


TypeStrengthLifetimeUML SymbolExample
AssociationWeakestIndependentSimple arrowTeacher → Student
AggregationWeakIndependentEmpty diamond ◊Department → Teachers
CompositionStrongDependentFilled diamond ◆House → Rooms
DependencyWeakest (temporary)TemporaryDashed arrowOrderService → PaymentService

graph TD
A[Class A] --o|Aggregation<br/>Weak has-a| B[Part B]
A --*|Composition<br/>Strong has-a| C[Part C]
A -.->|Dependency<br/>Uses temporarily| D[Service D]
A -->|Association<br/>Knows about| E[Related E]

TopicDescription
AssociationObjects knowing about each other
AggregationWeak has-a relationship
CompositionStrong has-a relationship
DependencyUsing other objects
Coupling vs CohesionMeasuring code quality

Previous Topic: Polymorphism → Next Topic: Association →