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 [2020-10-12 16:17] – old revision restored (2013-02-25 13:30) 159.69.186.191 | principles:information_hiding_encapsulation [2020-10-12 16:17] – old revision restored (2013-02-18 17:24) 159.69.186.191 | ||
---|---|---|---|
Line 20: | Line 20: | ||
===== Strategies ===== | ===== Strategies ===== | ||
- | | + | * Make all attributes private and use getter and setter methods to access them |
- | | + | * Better also avoid getters and setters |
- | * Better also avoid getters and setters | + | * Find suitable abstractions for data types and use appropriate methods instead of just getters and setters |
- | * Find suitable abstractions for data types and use appropriate methods instead of just getters and setters | + | * Generally use the lowest possible visibility for a variable or method |
- | * Avoid aliasing problems with value objects | + | * Use immutable objects or (if the programming language supports that) call-by-value objects (like stack objects in C++, structs in C#, records in Delphi, etc.) for value objects like '' |
- | * 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 '' | + | * Copy internal list objects before returning them or only return a read-only '' |
- | * Otherwise use immutable | + | |
- | | + | |
- | | + | |
===== Caveats ===== | ===== Caveats ===== | ||
principles/information_hiding_encapsulation.txt · Last modified: 2021-10-18 21:56 by christian