Difference between Abstraction and Encapsulation

This question is most common in interviews for programmers and many people are surprisingly very confused in their mind.I have found that following image says it all.No matter whether you are a programmer or not this will remain in your head.Bravo to my find!!

Difference between Abstraction and encapsulation

Advertisements

3 thoughts on “Difference between Abstraction and Encapsulation

  1. Pingback: Difference between Abstraction and Encapsulation

  2. Parag

    Hi Lalit,

    I am not sure if encapsulation would strictly refer to “hidden complexity”. Really speaking encapsulation is simply “bundling related data and methods” in the same class.

    Encapsulation in the above example would be bundling data and methods related to a TV set together. So if your TV’s power supply also performed the responsibility of switching channels then it would break encapsulation, because the responsibility of switching channels is not related to it’s main function of supplying power.


    Regards
    Parag

    Reply
  3. Lalit

    Thanks for replying!

    “So if your TV’s power supply also performed the responsibility of switching channels then it would break encapsulation”

    Certainly Parag,not only it breaks the encapsulation but it also breaks many other design principles like separation of concerns ,single responsibility as well.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s