NOTE
Law of Demeter
The Law of Demeter asks a class to know as little as possible about other objects' internals, reducing coupling.
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.
4. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub