Thursday, April 22, 2010

Abstraction vs Encapsulation


Abstraction is the process of taking a concept, identifying the attributes and behaviour and being able to turn that concept into code(Class) such that you will get an abstract view of the concept while Encapsulation is the process of organizing the required data types, methods to access them and defines a way to communicate through outer world, which mean's to get the job done.

In Object oriented programming abstraction is extremely important as by working more abstractly we can solve more and more difficult problems because we don’t have to concentrate on the lower level details.
  • “In another term we can say Abstraction comes first, Encapsulation satisfies what abstraction promise to do so.”
-Abstraction ask's to concentrate on “What” system does and encapsulation states “How” system does.


Elaborating topic more, For Abstraction we can say if we are not willing to know the cumbersome detailed information (because it might be too complex...) and willing to consider only meaningful data! Which help’s to "simplify" complex task and get clear arrangement/management.

While encapsulation shakes hands with if we didn’t want to let others access some important data and hence we put them within class and declare using access specifier. As a result, only the member functions can access them.

-Here I left one topic untouched i.e. information hiding, I will try to relate information hiding with this topic in next post.
-
*ASUS UL30A-X5 Thin and Light 13.3-Inch Black Laptop (12 Hours of Battery Life)

No comments:

Post a Comment