Lod — Law of Demeter

By Karol Bocian | February 29, 2020

Law Demeter

Talk only with your close friends.

Avoid code like that: School.GetWorkers().GetPersonData().GetName(). Every method can only call methods of:

  • Its object.
  • Parameters of its method.
  • Objects, which it creates.
  • Fields of its object


  • Less dependency between classes and modules.
  • Easier maintenance.
  • Lack of knowing details of calling objects.


  • Classes should have more methods.

All posts from mini project: Learn SOLID and OOP principles:


Main image


Leave a Reply

Your email address will not be published. Required fields are marked *