Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Encapsulation (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Bundling of data}} {{other uses|Encapsulation (disambiguation)}} 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.<ref name="Rogers01" /> Essentially, encapsulation prevents external code from being concerned with the internal workings of an object. Encapsulation allows developers to present a consistent interface that is independent of its internal implementation. As one example, encapsulation can be used to hide the values or state of a structured data object inside a [[Class (computer programming)|class]]. This prevents clients from directly accessing this information in a way that could expose hidden implementation details or violate [[State (computer science)|state]] invariance maintained by the methods. Encapsulation also encourages programmers to put all the code that is concerned with a certain set of data in the same class, which organizes it for easy comprehension by other programmers. Encapsulation is a technique that encourages [[Coupling (computer programming)|decoupling]]. All [[object-oriented programming]] (OOP) systems support encapsulation,<ref>{{Cite web |title=What is Object-Oriented Programming (OOP)? |url=https://www.techtarget.com/searchapparchitecture/definition/object-oriented-programming-OOP |access-date=2024-03-02 |website=App Architecture |language=en}}</ref><ref>{{Cite web |title=Encapsulation in Object Oriented Programming (OOPS) |url=https://www.enjoyalgorithms.com/blog/encapsulation-in-oops/ |access-date=2024-03-02 |website=www.enjoyalgorithms.com}}</ref> but encapsulation is not unique to OOP. Implementations of [[abstract data types]], [[module (programming)|modules]], and [[library (computing)|libraries]] also offer 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>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)