The Law of Demeter (Principle of Least Knowledge) states that an object’s method should only invoke methods of:
AAny global object anywhere in the application
BItself, its parameters, objects it instantiates, and its immediate direct component fields
CSubclasses located 3 levels deep in the inheritance tree
DRemote microservices without authentication
Explanation
The Law of Demeter restricts method call chains to immediate neighbors to prevent tight structural coupling.

No Comments