User:Hpesoj00/sandbox/Encapsulation (computer programming)

In computer science, data encapsulation or simply encapsulation is the application of the principle of information hiding, whereby certain design information is hidden from the users of an abstraction.

Definition
The term "encapsulation", or more specifically "procedural encapsulation", was used in 1973 by Stephen Zilles to describe how procedures can be used to encapsulate or "isolate" the underlying representation of a data type. He noted that encapsulation accomplishes three things: Encapsulation has since been described by Parnas and others as being synonymous with the "information hiding principle". Others have described encapsulation as referring to the way in which the operations that define the behaviour of an abstraction are associated or "bundled" with the definition or instance of the abstraction, while information hiding refers to the way in which the representation of an instance of the abstraction is hidden from view. More commonly, encapsulation is understood to be the application and enforcement of the information hiding principle through the use of language mechanisms such as procedures, modules and abstract data types.
 * 1) The operations defined on a type can be formalized to ensure the correctness of objects of that type
 * 2) Modules have to make minimal assumptions about other modules to which they have access
 * 3) Encapsulated data is protected from both accidental and malicious modification

Information hiding principle
The concept of "information hiding" was described in 1971 by David Parnas, who proposed that access to information should be restricted by design in order to reduce the interconnectedness of a system. He described three apparently conflicting design concerns: Parnas suggested that these concerns could more easily be reconciled if design information were not accessible to everyone. He proposed that programmers should not be responsible for deciding which information to use, but instead system designers should restrict the information that is available to programmers. He gave an example of how to document a module with a formal interface definition so as to hide implementation details from the user.
 * 1) The desire to have a user-friendly external interface
 * 2) The desire to reduce development time by splitting a system into modules that can be designed independently
 * 3) The desire to easily change the implementation details of a system

Parnas later showed how information hiding can be used as a design criterion for dividing a system into modules. By defining the interfaces between modules such that they hide design decisions from each other, he suggested that a system can support a wider range of functionality without having to change the interface definitions. He noted that care must be taken to ensure that decomposing a system in this way does not negatively impact efficiency.

In 1975, Parnas discussed how attempting to deal with errors at the point where they occur violates the "information hiding principle"; he suggested that interfaces between modules should be designed to communicate information about errors, error handling, and assumptions.

In 1976, Parnas et al. described how programming languages that support abstract data types enable the programming methodology of information hiding.