Abstraction vs Encapsulation

Abstraction and Encapsulation are the two basic features of Object Oriented Programming.

  • Abstraction – Refers to the process of exposing only the relevant and essential data to the users without showing unnecessary information. It lets you focus on what the object does, instead of how it does it.
  • Encapsulation – Prevents the data from unwanted access by binding of code and data into a single unit.

 

                           Abstraction                             Encapsulation
Abstraction means to show only what is necessary. Encapsulation means to hide complexity.
Abstraction solves the problem in the design level. Encapsulation solves the problem in the implementation level.
Abstraction is implemented using interface and abstract class. Encapsulation is implemented using private and protected access modifier.
Abstraction is “To represent the essential feature without representing the back ground details.” Encapsulation means hiding the internal details of an object, i.e. how an object does something.
Abstraction provides you a generalized view of your classes or object by providing relevant information. Encapsulation means hiding details of implementation from outside world so that, when things change nobody gets affected. Encapsulation is also called data hiding.

 



Categories: C#, Object Oriented Programming

4 replies

  1. Hey very interesting blog!

  2. Hello there! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m definitely enjoying your blog and look forward to new posts.

  3. Hey Thomas…Thanks for your feedback. My twitter handle is @samirbehara
    https://twitter.com/samirbehara

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: