Law of Demeter

Law of Demeter: If two classes do not have to communicate directly with each other, then the two classes should not interact directly. If one class needs to call a method of the other class, it can be forwarded through a third party Call. It emphasizes that in the structural design of the class, each class should try to reduce the access rights of members.

The fundamental idea of ​​the Law of Demeter is to emphasize the loose coupling between classes. The weaker the coupling between classes, the more Conducive to reuse, a class in weak coupling is modified without affecting related classes

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326506708&siteId=291194637
law