Encapsulation (computer programming)

Bundling of data / From Wikipedia, the free encyclopedia

Dear Wikiwand AI, let's keep it short by simply answering these key questions:

Can you list the top facts and stats about Encapsulation (object-oriented programming)?

Summarize this article for a 10 years old


In software systems, encapsulation refers to the bundling of data with the mechanisms or methods that operate on the data. It may also refer to the limiting of direct access to some of that data, such as an object's components.[1] Encapsulation allows developers to present a consistent and usable interface which is independent of how a system is implemented internally. As one example, encapsulation can be used to hide the values or state of a structured data object inside a 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.

All object-oriented programming (OOP) systems support encapsulation [citation needed], but encapsulation is not unique to OOP. Implementations of abstract data types, modules, and libraries, among other systems, also offer encapsulation. The similarity has been explained by programming language theorists in terms of existential types.[2]