Source:
http://en.wikipedia.org/wiki/Law_of_Demeter
The Law of Demeter (LoD), or Principle of Least Knowledge, is a simple design style for developing software, particularly object-oriented programs. In this general form, the LoD is a more specific case of the Low Coupling Principle.
A disadvantage of the Law of Demeter is that it sometimes requires writing a large number of small “wrapper” methods (sometimes referred to as Demeter Transmogrifiers) to propagate method calls to the components
http://en.wikipedia.org/wiki/Law_of_Demeter
The Law of Demeter (LoD), or Principle of Least Knowledge, is a simple design style for developing software, particularly object-oriented programs. In this general form, the LoD is a more specific case of the Low Coupling Principle.
- Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
- Each unit should only talk to its friends; don't talk to strangers.
- Only talk to your immediate friends.
- O itself
- M's parameters
- any objects created/instantiated within M
- O's direct component objects
- a global variable, accessible by O, in the scope of M
A disadvantage of the Law of Demeter is that it sometimes requires writing a large number of small “wrapper” methods (sometimes referred to as Demeter Transmogrifiers) to propagate method calls to the components
No comments:
Post a Comment