From charlesreid1

Revision as of 18:27, 18 June 2017 by Admin (talk | contribs) (Created page with "Encapsulation: public/private. Deciding what we expose to the outside world, versus what we keep protected, versus what we keep private: ''Always make everything as private...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Encapsulation: public/private.

Deciding what we expose to the outside world, versus what we keep protected, versus what we keep private:

Always make everything as private as possible.

If you find that it's difficult to thoroughly test a class, then the class may be doing too much. Splitting the class up using composition can make the individual units more testable.



A few heuristics:

  • Decomposition
  • Abstraction
  • Subset identification
  • Information hiding
  • Virtual structuring
  • Modularity
  • Separating policy and mechanism
  • Hierarchy

A few more heuristics:

  • Visibility of system status - keep status of things visible to users.
  • Match between system and world - keep verbiage and symbols system-oriented.
  • User control - allow users ability to leave unwanted state.
  • Consistency - maintain consistency across interfaces.
  • Error prevention - try and anticipate and prevent errors.
  • Recognition, not recall - make things visible, not things they have to retrieve
  • Flexibility - things should be flexible across situations
  • Accelerators - things unseen by novice users, allow speeding up interaction by expert users.
  • Minimal - keep it simple.