Saturday 19 October 2013

Difference between abstraction and encapsulation

After introducing the concept of Object Oriented Programming and its main parts, lets compare and contrast abstraction and encapsulation :

Abstraction :

  • Solves our problem using an outer shell in terms of  "design"
  • Its used to hide the unwanted and un relevant data from the user.
  • Focuses more on what the object actually does rather on how it does it.
  • Example : The display of a touch screen.
Encapsulation:

  • Solves our problem in the implementation level instead.
  • It is used to hide the code and data into one single unit and hide it from the external world.
  • Focuses on hiding the internal details and mechanics of an object, i.e. how the object does it.
  • Example : How the display screen is connected with dialling option using circuits.


No comments:

Post a Comment