architect-handbook

Software Architect Handbook

View on GitHub

Least Knowledge

The Principle of Least Knowledge guides us to reduce the interactions between objects to just a few close friends. This means you should be careful of the number of classes an object interacts with and also how it comes to interact with those classes.

This principle prevents us from creating designs that have a large number of classes coupled together so that changes in one part of the system cascade to another parts.

Take any object, from any method in that object, the principle says we should only invoke methods that belong to:

Notice that these guidelines tell us not to call methods on objects that were returned from calling other methods.