Encapsulation (computer programming): Difference between revisions

Content deleted Content added
This part does not related with encapsulation at all. It could be moved to an article about Anti-patterns or another place but it should not be here.
Tags: Reverted Visual edit
Undid revision 1097723294 by 46.238.28.74 (talk) unsourced
Tags: Undo Reverted
Line 1:
{{Short description|Bundling of data}}
In [[object-oriented programming]] (OOP), '''encapsulation''' refers to the bundling of data with the methods that operate on that data., Often that definition is misconstrued to mean thator the datarestricting isof somehowdirect hidden.access Into Java,some youof canan haveobject's encapsulated data that is not hidden at allcomponents. So '''encapsulation''' and '''hidding''' are not the same and have different meaning! <ref name="Rogers01" /> Encapsulation is used to hide the values or state of a structured data object inside a [[Class (computer programming)|class]], preventing direct access to them by clients in a way that could expose hidden implementation details or violate state invariance maintained by the methods.
 
This mechanism is not unique to OOP. Implementations of [[abstract data types]], e.g., [[module (programming)|modules]], offer a similar form of encapsulation. The similarity has been explained by programming language theorists in terms of [[existential types]].<ref>{{harvnb|Pierce|2002|loc=§ 24.2 Data Abstraction with Existentials}}</ref>