Law of Demeter

The Law of Demeter introduced by Assuring Good Style for Object-Oriented Programs# states that each method or function can send messages to their preferred-supplier objects, that is, argument objects, itself, objects either created in the method or in global scope, and the immediate subpart of self such as elements or object instantiated within the class. This also means that they should call only methods belonging to itself, parameters passed into the method (class type object), objects created within the method or its class. The Pragmatic Programmer

By obeying the law, the code base would be easier to maintain and comprehend as the dependencies between classes are lesser and better organised.

Links to this page
  • SOLID

    Write shy codes: don’t reveal yourself to others, and don’t interact with too many people. The Pragmatic Programmer By that, the interaction between the modules or interfaces is limited so if one get comprised, the others remained unaffected. Make sure the implementation of the interface is adhered to the 202207031635#.

#oop