Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Association

Classes that know about each other and can communicate.

Association is a relationship where one class knows about another class and can use its services. It’s a “uses-a” or “knows-a” relationship where classes can exist independently.

Association represents a relationship where:

  • Classes know about each other
  • Classes can communicate with each other
  • Classes have independent lifecycles
  • Usually implemented with references or pointers
  • Independent existence - Both classes can exist without each other
  • Communication - Classes can call each other’s methods
  • References - One class holds a reference to another
  • Weaker than composition - No ownership implied

One class knows about another, but not vice versa.

Both classes know about each other.

Diagram

Use Association when:

  • Classes need to communicate with each other
  • Classes have independent lifecycles
  • One class uses another’s services
  • You need flexibility to change relationships
  • Classes are loosely coupled

Examples:

  • Teacher ↔ Course
  • Student ↔ Course
  • Order ↔ Product
  • Loan ↔ Book
  • Customer ↔ Order

💡 Time to Practice!

Now that you understand the concepts, put them into practice with our interactive playground. Build UML diagrams, write code, and get AI-powered feedback.

Browse All Problems