Encapsulation (computer programming): Difference between revisions

Content deleted Content added
m Reverted edits by 112.208.94.89 (talk) to last version by Freshacconci
Line 101:
== General definition ==
 
In general, encapsulation '''is one of the four fundamentals''' of OOP ([[object-oriented programming]]). Encapsulation is '''used to hide the values or state of a structured data object''' inside a class, preventing unauthorized parties direct access to them. Publicly accessible methods are generally provided in the class (so-called ''getters'' and ''setters'') to access the values, and other client classes call these methods to retrieve and modify the values within the object.
 
This mechanism is not unique to object-oriented programming. Implementations of [[abstract data types]], e.g. [[module (programming)|modules]], offer a similar form of encapsulation. This similarity stems from the fact that both notions rely on the same mathematical fundament of an [[existential type]].<ref>Pierce (2002), Section 24.2 "Data Abstraction with Existentials"</ref>