The Principle of Least Knowledge

  1. The Principle of Least Knowledge guides us to reduce the interactions between objects to just a few close “friends”.
  2. When you are designing a system, for any object, be careful of the number of classes it interacts with and also how it comes to interact with those classes.
  3. 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 other parts. When you build a lot of dependencies between many classes, you are building a fragile system that will be costly to maintain and complex for others to understand.

Links to this note