Tag: the link exists completely, and the English contact is sent to the entity.
Law of Demeter)
Also known as the least knowledge principle (LKP.
This is a guiding principle for object-oriented programming. It describes a policy to maintain loose code coupling.
The DEMETER rule can be simply described as: talk only to your immediate friends.
That is, you can only talk to your "friends" directly.
For Ood, it is also interpreted as the following methods:
A software entity should interact with other entities as little as possible.
Each software organization has only the minimum knowledge of other units and is limited to software units closely related to the same unit.
The original intention of the dimit rule is to reduce coupling between classes.
As each class should minimize its dependence on other classes, it is easy to make the functional modules of the system independent of each other and there is no (or few) dependency between them.
The dimit rule does not require a direct connection between classes. If you really need to establish a connection, you also hope to convey it through its membership class.
Therefore, the application of the Demeter rule may result in a large number of intermediary classes in the system, these classes exist completely to pass the mutual call relationship between classes, which increases the complexity of the system to a certain extent.
For example, the facade mode (facade) and mediator mode of the design mode are examples of the application of the Demeter rule.
Object-Oriented Design Principles Law of Demeter)