principles:information_hiding_encapsulation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
principles:information_hiding_encapsulation [2021-02-02 18:56] – old revision restored (2021-02-01 19:42) 95.216.157.202 | principles:information_hiding_encapsulation [2021-02-02 18:58] – old revision restored (2020-12-10 07:39) 95.216.157.202 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Information Hiding/ | + | ====== Information Hiding/ |
===== Variants and Alternative Names ===== | ===== Variants and Alternative Names ===== | ||
+ | |||
+ | * Parnas' | ||
Line 19: | Line 21: | ||
===== Strategies ===== | ===== Strategies ===== | ||
+ | |||
+ | * Use the lowest possible visibility for a variable or method | ||
+ | * Make all attributes private and use getter and setter methods to access them | ||
+ | * Better also avoid getters and setters | ||
+ | * Find suitable abstractions for data types and use appropriate methods instead of just getters and setters | ||
+ | * Avoid aliasing problems with value objects | ||
+ | * If the programming language supports that use call-by-value objects (like stack objects in C++, structs in C#, records in Delphi, etc.) for value objects like '' | ||
+ | * Otherwise use immutable objects which are handled call-by-reference but needn' | ||
+ | * Avoid aliasing problems with lists and similar data structures | ||
+ | * Copy internal list objects before returning them or only return a read-only '' | ||
+ | |||
+ | |||
+ | ===== Caveats ===== | ||
+ | |||
+ | See section [[#contrary principles]]. | ||
===== Origin ===== | ===== Origin ===== | ||
+ | |||
+ | David Parnas: //On the Criteria To Be Used in Decomposing Systems into Modules// | ||
Line 32: | Line 51: | ||
* [[wiki: | * [[wiki: | ||
*/ | */ | ||
+ | |||
===== Relations to Other Principles ===== | ===== Relations to Other Principles ===== | ||
Line 41: | Line 61: | ||
==== Contrary Principles ==== | ==== Contrary Principles ==== | ||
- | * [[principles:Keep It Simple Stupid]] | + | * [[Keep It Simple Stupid]] |
==== Complementary Principles ==== | ==== Complementary Principles ==== | ||
- | * [[principles:Model Principle]] | + | * [[Model Principle]] |
- | * [[principles:Liskov Substitution Principle]] | + | * [[Liskov Substitution Principle]] |
- | * [[principles:Invariant Avoidance Principle]] | + | * [[Tell, don't Ask/Information Expert]] |
- | * [[principles:Information Expert]] | + | * [[Low Coupling]] |
- | * [[principles:Low Coupling]] | + | * [[Principle of Separate |
- | * [[principles:Principle of Separate | + | * [[Easy to Use and Hard to Misuse]] (EUHM): A module should be properly encapsulated in order to make it easy to use and hard to misuse. |
==== Principle Collections ==== | ==== Principle Collections ==== | ||
Line 58: | Line 79: | ||
- | ===== Example | + | ===== Examples |
Line 66: | Line 87: | ||
/ | / | ||
/ | / | ||
+ | |||
===== Further Reading ===== | ===== Further Reading ===== | ||
+ | * [[wiki> | ||
+ | * [[wp> | ||
+ | |||
+ | * [[wiki> | ||
+ | * [[wp> | ||
+ | |||
+ | * [[http:// | ||
+ | * [[wiki> | ||
+ | * [[wiki> |
principles/information_hiding_encapsulation.txt · Last modified: 2021-10-18 21:56 by christian