principles:tell_don_t_ask_information_expert
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
principles:tell_don_t_ask_information_expert [2013-02-25 10:46] – [Caveats] christian | principles:tell_don_t_ask_information_expert [2021-09-02 20:51] – old revision restored (2021-03-28 06:12) 65.21.179.175 | ||
---|---|---|---|
Line 15: | Line 15: | ||
===== Principle Statement ===== | ===== Principle Statement ===== | ||
- | Assign a responsibility to this [[glossary: | + | * Assign a responsibility to that [[glossary: |
+ | * Don't ask an object for information, | ||
===== Description ===== | ===== Description ===== | ||
Line 25: | Line 25: | ||
===== Rationale ===== | ===== Rationale ===== | ||
- | When this principle is not adhered to, then a module has a responsibility for which it is lacking some information. So in order to fulfill the task the module has to first acquire the needed information by invoking other modules. This increases the dependencies between the modules (which may lead to[[glossary: | + | When this principle is not adhered to, then a module has a responsibility for which it is lacking some information. So in order to fulfill the task the module has to first acquire the needed information by invoking other modules. This increases the dependencies between the modules (which may lead to [[glossary: |
===== Strategies ===== | ===== Strategies ===== | ||
+ | * Assign a responsibility to the class that has the largest subset of the needed information. | ||
+ | * Mirror functionality of composed objects to the interface of the class instead of having a getter-method returning the composed object | ||
+ | * Have the objects operate on their own data using appropriate methods. Avoid getters and setters. | ||
===== Caveats ===== | ===== Caveats ===== | ||
Line 55: | Line 57: | ||
==== 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 67: | Line 66: | ||
==== 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 [[# | ||
+ | * [[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 [[# | ||
* [[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/ | * [[Information Hiding/ | ||
+ | * [[Principle of Separate Understandability]] (PSU): TdA/IE is about responsibility assignment. Another aspect of this task is treated by PSU. | ||
==== Principle Collections ==== | ==== Principle Collections ==== | ||
Line 76: | Line 78: | ||
- | ===== Example | + | ===== Examples |
principles/tell_don_t_ask_information_expert.txt · Last modified: 2021-10-18 21:42 by christian