User Tools

Site Tools


principles:law_of_demeter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
principles:law_of_demeter [2020-10-12 16:20] – old revision restored (2013-02-18 17:24) 159.69.186.191principles:law_of_demeter [2021-10-18 21:52] (current) – +++ restored +++ christian
Line 9: Line 9:
 /* fill in contexts here: */ /* fill in contexts here: */
   * [[contexts:Object-Oriented Design]]    * [[contexts:Object-Oriented Design]] 
 +  * [[contexts:Implementation]]
  
 ===== Principle Statement ===== ===== Principle Statement =====
Line 51: Line 51:
 ==== Generalizations ==== ==== Generalizations ====
  
-  * [[principles:Low Coupling]]: The goal of LoD is to reduce coupling by reducing the knowledge of a class about other classes. +  * [[Low Coupling]] (LC): The goal of LoD is to reduce coupling by reducing the knowledge of a class about other classes. 
-  * [[principles:Tell, Don't Ask]]+  * [[Tell, Don't Ask/Information Expert]] (TdA/IE): LoD is more specific than TdA/IE because TdA/IE can be applied in a wider context (e.g. for responsibility assignment). Applying TdA leads to solutions which are good according to LoD. Note that the reverse is not true: Accoring to LoD you may get and set values from an object passed as a parameter to a method.
  
 ==== Specializations ==== ==== Specializations ====
Line 58: Line 58:
 ==== Contrary Principles ==== ==== Contrary Principles ====
  
-  * [[principles:More Is More Complex]]: Adhering to the Law of Demeter often results in additional methods. +  * [[More Is More Complex]] (MIMC): Adhering to the Law of Demeter often results in additional methods. 
-  * [[principles:Low Coupling]]: Adhering to the Law of Demeter may create tramp couplings which are bad. +  * [[Low Coupling]] (LC): Adhering to the Law of Demeter may create tramp couplings which are bad. 
-  * [[principles:High Cohesion]]: Adhering to the Law of Demeter often results in additional methods that mirror methods of aggregated objects. As these objects have other responsibilities, the additional methods have fewer commonalities with the "real" methods of the class, which results in a lower cohesion.+  * [[High Cohesion]] (HC): Adhering to the Law of Demeter often results in additional methods that mirror methods of aggregated objects. As these objects have other responsibilities, the additional methods have fewer commonalities with the "real" methods of the class, which results in a lower cohesion.
  
 ==== Complementary Principles ==== ==== Complementary Principles ====
 +
 +  * [[Model Principle]] (MP): Adhering to LoD may result in additional methods in aggregating classes. MP tells how they should look like.
 +
  
 ==== Principle Collections ==== ==== Principle Collections ====
  
  
-===== Example =====+===== Examples =====
  
  
Line 87: Line 90:
   * Phil Haack: //[[http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx|The Law of Demeter Is Not A Dot Counting Exercise]]//   * Phil Haack: //[[http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx|The Law of Demeter Is Not A Dot Counting Exercise]]//
   * [[http://www.ccs.neu.edu/home/lieber/LoD.html|Law of Demeter]]   * [[http://www.ccs.neu.edu/home/lieber/LoD.html|Law of Demeter]]
 +
 +===== Discussion =====
 +
 +Discuss this wiki article and the principle on the corresponding [[talk:principles:Law of Demeter|talk page]].
  
principles/law_of_demeter.1602512434.txt.gz · Last modified: 2020-10-12 16:20 by 159.69.186.191