Pages

Wednesday, January 22, 2014

Decoupling and the Law of Demeter (Part 2)

The Law of Demeter for Functions

The law of demeter for functions helps to reduce coupling between modules. The law states that any method of an object should call only methods belonging to:

  • itself
  • any parameters that were passed into the method
  • any objects it created
  • any directly held component objects

Writing shy code which obeys this law helps us to achieve our objective:

Minimize Coupling Between Modules

Using the Law of Demeter will make our code more adaptable and robust.


- summary of Decoupling and the Law of Demeter, from The Pragmatic Programmer: From Journeyman to Master

No comments:

Post a Comment