Encapsulation is a technique for minimizing interdependencies among separately written modules by defining strict external interfaces. The external interface of a module serves as a contract between the module and its clients and thus between the designer of the module and other designers.
This definition by Snyder highlights module encapsulation. A module is probably encapsulated when the clients are restricted by the characterization of the programming language to access the module through the external interfaces defined by the program. Encapsulation hence guarantees designers that changes that are compatible can be made safely, which makes possible evaluation of programs and their maintenance. These benefits are especially important for large systems and long-lived data. In order to make the most of the advantages of encapsulation, it is important to minimize the exposure of implementation details in external interfaces. The support a programming language has to encapsulation extends only to the degree that it allows the least external interfaces to be defined and enforced. This support can be characterized by the kinds of changes that can safely be made to the implementation of a module. For instance, one characteristic of an OOM is whether it allows a designer to define a class in such a way that its instance variables can be renamed without affecting clients.
Another form of encapsulation is object encapsulation. An object encapsulation technique does not facilitate code evolution, but it increases the reliability of the code. This is done by allowing the programmer to implement data structures whose instances are guaranteed to be protected from the lure of out-of-place operations on their sub-objects. Presently, the majority of the statically typed object-oriented languages such as Java, C++, and C# offer moderately good support for module encapsulation, and many proposals have been made for augmenting the static type systems of such languages so that they can also express object encapsulation.