User Tools

Site Tools


principles:tell_don_t_ask_information_expert

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
Next revisionBoth sides next revision
principles:tell_don_t_ask_information_expert [2013-02-12 16:21] – -PSU christianprinciples:tell_don_t_ask_information_expert [2021-09-02 12:51] – old revision restored (2021-05-11 22:31) 65.21.179.175
Line 3: Line 3:
 ===== Variants and Alternative Names ===== ===== Variants and Alternative Names =====
  
-  * Expert +  * Information Expert or Expert in ((Craig Larman: //Applying UML and Patterns – An Introduction to Object-Oriented Analysis and Design and Iterative Development//)) 
-  * Do It Myself+  * Do It Myself in ((Peter Coad: //Object Models: Strategies, Patterns and Applications// -- as stated in Craig Larman: //Applying UML and Patterns – An Introduction to Object-Oriented Analysis and Design and Iterative Development//, p. 297)) 
 +  * Tell, don't Ask in ((Andrew Hunt and David Thomas: //[[http://www.ccs.neu.edu/research/demeter/related-work/pragmatic-programmer/jan_03_enbug.pdf|The Art of Enbugging]]// -- probably not the original source of this wording(?) ))
  
  
Line 28: Line 29:
  
 ===== Strategies ===== ===== Strategies =====
 +
 +
 +===== Caveats =====
 +
 +Sometimes assigning responsibilities using IE results in bas solutions (high coupling, low cohesion). This is because IE just focuses on the availability of data. So for example IE would demand domain objects saving themselves to the database. This is bad since it couples the domain objects to the database interface (JDBC, SQL, etc.) and lowers cohesion by adding unrelated responsibilities to the classes. Here it is better to give the task of persisting the domain objects to a separate class.((see Craig Larman: //Applying UML and Patterns – An Introduction to Object-Oriented Analysis and Design and Iterative Development//, p. 298))
 +
 +See also section [[#contrary principles]].
  
  
Line 47: Line 55:
  
 ==== Generalizations ==== ==== Generalizations ====
- 
-  * [[Low Coupling]] Adhering to the information expert principle leads to low coupling as there is less need to communicate with other modules to get the necessary information. 
-  * [[High Cohesion]] Adhering to information expert also means that a module only has responsibilities which belong together. So this increases cohesion. 
  
 ==== Specializations ==== ==== Specializations ====
Line 59: Line 64:
 ==== Complementary Principles ==== ==== Complementary Principles ====
  
 +  * [[Low Coupling]] Adhering to IE typically leads to low coupling as there is less need to communicate with other modules to get the necessary information. But in some cases IE also increases coupling (see [[#caveats]]. 
 +  * [[High Cohesion]] Adhering to IE typically leads to high cohesion as responsibilities which belong together typically operate on the same data. But in some cases IE also lowers cohesion (see [[#caveats]]. 
   * [[Model Principle]] (MP): TdA/IE tells how to distribute functionality among the natural classes which are created according to the Model Principle.   * [[Model Principle]] (MP): TdA/IE tells how to distribute functionality among the natural classes which are created according to the Model Principle.
   * [[Information Hiding/Encapsulation]] (IH/E): Assigning responsibilities to objects using Information Expert may accidentally break encapsulation. It typically does not but it has to be considered. Furthermore TdA is about not having getter methods returning constituent parts of a module. Encapsulation can be another reason for that.   * [[Information Hiding/Encapsulation]] (IH/E): Assigning responsibilities to objects using Information Expert may accidentally break encapsulation. It typically does not but it has to be considered. Furthermore TdA is about not having getter methods returning constituent parts of a module. Encapsulation can be another reason for that.
principles/tell_don_t_ask_information_expert.txt · Last modified: 2021-10-18 21:42 by christian