Difference between Abstraction, Encapsulation and Information Hiding

Posted on Friday, June 5, 2009


So this one completes the hat-trick on blogs related to differences in succession.

Today during our discussion about defining service orchestrations we came up with the argument about the difference between Encapsulation and Information hiding. I cover abstraction here as a bonus ;)

Abstraction – in a nutshell is making visible what you want the external world to see and keeping the other details behind the wraps. Abstraction, as a process, denotes the extracting of the essential details about an item, or a group of items, while ignoring the inessential details. It hides the complexity. It is a technique by which we decide what information to hide and what to expose.

Information hiding - is making inaccessible certain details which would not affect other parts of the system. Just hiding it so that it is not exposed.

Encapsulation - is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.If encapsulation was “the same thing as information hiding,” then one might make the argument that “everything that was encapsulated was also hidden.” This is obviously not true. For example, even though information may be encapsulated within record structures and arrays, this information is usually not hidden and is available for use. Encapsulation is just getting a set of operations and data together which belong together and putting them in a capsule.

Abstraction, information hiding, and encapsulation are different but related. Abstraction is a technique that helps us identify which specific information should be visible, and which information should be hidden. Encapsulation is the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible. Encapsulation can be thought of as the implementation of the abstract class.

About these ads
Posted in: Architecture