Search code examples
encapsulationabstractionglossaryooadinformation-hiding

Abstraction VS Information Hiding VS Encapsulation


Can you tell me what is the difference between abstraction and information hiding in software development?

I am confused. Abstraction hides detail implementation and information hiding abstracts whole details of something.

Update: I found a good answer for these three concepts. See the separate answer below for several citations taken from there.


Solution

  • Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition):

    Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object... encapsulation focuses upon the implementation that gives rise to this behavior... encapsulation is most often achieved through information hiding, which is the process of hiding all of the secrets of object that do not contribute to its essential characteristics.

    In other words: abstraction = the object externally; encapsulation (achieved through information hiding) = the object internally,

    Example: In the .NET Framework, the System.Text.StringBuilder class provides an abstraction over a string buffer. This buffer abstraction lets you work with the buffer without regard for its implementation. Thus, you're able to append strings to the buffer without regard for how the StringBuilder internally keeps track of things such the pointer to the buffer and managing memory when the buffer gets full (which it does with encapsulation via information hiding).

    rp