Software Engineering Architecture Lab

Encapsulation, Tell Don’t Ask & the Law of Demeter

Put behaviour next to the data it protects, and stop reaching through objects. Lesson 6 of Level 3: Object-Oriented Design.

Level 3 · Object-Oriented Design · Lesson 6 of 6

Put behaviour next to the data it protects, and stop reaching through objects.

Continue learning

All lessons in OO Design

  1. Single Responsibility: One Reason to Change
  2. Open/Closed: Add Features Without Editing Old Code
  3. Liskov Substitution: Subtypes That Keep Their Promises
  4. Interface Segregation & Dependency Inversion
  5. Composition Over Inheritance
  6. Encapsulation, Tell Don’t Ask & the Law of Demeter