NOTE
Law of Demeter
What the Law of Demeter is, why it is needed, and how to reduce coupling by limiting what objects depend on and expose.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is the Law of Demeter?
Do not know what you do not need to know. A class should keep its knowledge of other objects to a minimum.
2. Why Is the Law of Demeter Needed?
Reduce coupling.
3. Implementing the Law of Demeter
From the perspective of the dependent object, depend only on the objects that should be depended on.
From the perspective of the object being depended on, expose only the methods that should be exposed.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub