Object Relationships
Object Relationships
Section titled “Object Relationships”Introduction
Section titled “Introduction”Objects in a system don’t exist in isolation — they relate to each other. Understanding object relationships is crucial for designing flexible, maintainable systems.
Relationship Types
Section titled “Relationship Types”| Type | Strength | Lifetime | UML Symbol | Example |
|---|---|---|---|---|
| Association | Weakest | Independent | Simple arrow | Teacher → Student |
| Aggregation | Weak | Independent | Empty diamond ◊ | Department → Teachers |
| Composition | Strong | Dependent | Filled diamond ◆ | House → Rooms |
| Dependency | Weakest (temporary) | Temporary | Dashed arrow | OrderService → PaymentService |
Visual Overview
Section titled “Visual Overview”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]Topics in This Section
Section titled “Topics in This Section”| Topic | Description |
|---|---|
| Association | Objects knowing about each other |
| Aggregation | Weak has-a relationship |
| Composition | Strong has-a relationship |
| Dependency | Using other objects |
| Coupling vs Cohesion | Measuring code quality |
Previous Topic: Polymorphism → Next Topic: Association →