See all glossary termsEncapsulation is the principle of hiding implementation details, and presenting a limited Interface to the outside world. Encapsulation is used to prevent users from accessing the internal state of an object directly, without restricting the ways in which the data can be manipulated.
By presenting a limited interface, programmers developing that part are free to change the internal implementation without affecting all the objects using the code, as long as they maintain the same external interface.
It also makes switching an implementation with another easier, if both present the same interface.
The idea of encapsulation is mostly useful in large teams, where there isn't a lot of communication or coordination. Different teams can work on different parts of the codebase without needing to know how the other parts work internally, as long as they know how to interact with them.
Encapsulation is a concept that is usually used in the context of Object Oriented Programming, but this idea predates it and can be applied to any programming paradigm that bundles data and behavior together. Some languages for example use modules to encapsulate data and functions.See Also
Related terms in the Glossary
school.gdquest.com - 0.3.5-2024-11-14T22:16:40.217Z-