Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>You may want to read the <a href="http://en.wikipedia.org/wiki/Encapsulation_(computer_science)" rel="noreferrer">Information Hiding</a> topic on wikipedia.</strong></p> <p><strong>Essentially, private members allow a class to hide its implementation details from external consumers.</strong> This allows a class to better control how it data and behavior will be expressed, and allows the consumer to be ignorant of details that are not relevant to the primary purpose of the class. </p> <p><strong>Hiding implementation details improves the maintainability of a program</strong> by preventing code external from the class from establishing dependencies on those details. This allows the implementation to change independent of external consumers - with a reduced risk of breaking existing behavior. When private implementation details become public, they cannot be changed without the possibility of breaking consumers of the class that depend on those details.</p> <p><strong>Private members also allow a class to protect it's implementation from external abuse.</strong> Typically, the state of a class has internal dependencies which define when the state is valid - and when it is not. We can consider the rules that govern the validity of state information to be <em>invariant</em> - meaning that the class always expects them to be true. Exposing private details, allows external code to modify this state in a way that may violate the invariants, and therefore compromise the validity (and behavior) of the class.</p> <p><strong>An additional benefit of information hiding, is that it reduces the <em>surface area</em> that consumers of the class have to understand</strong> in order to properly interact with the class. Simplification is generally a <em>good thing</em>. It allows consumers to focus on understanding the public interface, and not how the class achieves its functionality.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload