Tuesday, May 15, 2007

Encapsulation

Encapsulation is another element of OOPS. I have felt that Encapsulation is very close to abstraction. A different perspective of Abstraction....? Both are linked together, I assume. Abstraction is something that is existent because of Encapsulation. Abstraction is a principle or quality while Encapsulation is a technique. Encapsulation is possible because Objects do have a quality called Abstraction.

I remember someone told me that Abstraction is implemented through Encapsulation.

There is another definition-"Wrapping up of data and function together in a same entity called class". I don't like this one! I have heard this many times interviewers uttering. Its a too narrowed down,Programming specific definition. Object Orientation and thus Encapsulation is not only a programming language specific discipline.It has much broader aspects that it is there in the universe.When these qualities are disappeared (or taken away by God!) we human beings have to adopt different means for interacting, apprehending everything around us!

Hence I go for this one.
"The process of hiding all the details of an object
that do not contribute to its essential characteristics; typically,
the structure of an object is hidden, as well as the implementation of
its methods. The terms information hiding and encapsulation are usually
interchangeable."


This again comes from Booch.

When u pushed the break pedal in ambassador car ,you didn't care that had a hydraulic or air break. While doing the same thing on a Benz, u never bothered whether the model had ABS. All those were smartly encapsulated inside and u have abstraction in the form of a 'pedal push'. 'All well hidden inside'.

I just replaced my Computer RAM knowing that it was non functioning. It was quite easier to push the new RAM in to the slot. Now my PC is OK! I just did without having chip level expertise. Encapsulation helped here.

There is one thing to note here -'Degree of Abstraction'.

I am actually trying to redefine my ideas.I see a plenty of authentic material in web which are quite helpful.

1 comment:

Unknown said...

nice blog man, keep on the good work