user1765876
user1765876

Reputation:

Information hiding is abstraction or encapsulation?

The title says it all, I am bit confused as I was asked a question that Information handling in term of OOP is abstraction or encapsulation? I opted for abstraction but still I am confused because in encapsulation we also hide the fields and in abstraction we hide the details. Any help in this regard

Upvotes: 1

Views: 228

Answers (4)

humam
humam

Reputation: 191

Here is a nice answer that I think it clears the confusion

Encapsulation has two faces; data abstraction and information hiding. Data abstraction is a type seen from the outside. Information hiding is a type seen from the inside.

  • Abstraction focuses on the outside view of an object (i.e. the interface)
  • Encapsulation (information hiding ) prevents clients from seeing its inside view, where the behavior of the abstraction is implemented

Upvotes: 1

sallushan
sallushan

Reputation: 1147

Encapsulation = Hiding the Complexities / information

Abstraction = A (somewhat) defined way to handle complexities, using encapsulation

Upvotes: 0

Wasif Hossain
Wasif Hossain

Reputation: 3950

Abstraction generally hides information, while Encapsulation separates the changeable data from the unchanged one. In this way, Encapsulation helps to achieve the Open Closed Principle.

Upvotes: 1

David Wilkins
David Wilkins

Reputation: 584

It may help if you think of encapsulation as one of the tools used to create abstraction. See the wikipedia entry for encapsulation here http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)

Upvotes: 1

Related Questions