The Many Forms of Demeter
The formal object form of the law can be summarized as:
A method of an object may only call methods of:
- The object itself.
- An argument of the method.
- Any object created within the method.
- Any direct properties/fields of the object.
Each unit should have only limited knowledge about other units: only units "closely" related to the current unit. Or: Each unit should only talk to its friends; Don’t talk to strangers.
This of course leads to the succinct form of the law:
Don’t talk to strangers
No comments:
Post a Comment