Search code examples
oopencapsulationabstractioninformation-hiding

Is encapsulation a subset of abstraction?


As both encapsulation and abstraction relate to information hiding, can I understand encapsulation as a subset of abstraction?


Solution

  • Encapsulation is just one way of achieving abstraction.

    'abstraction' is a concept, it is the idea of defining or understanding a particular 'thing' (whatever that may be) through its essential properties or behaviors.
    'encapsulation' is a computer science technique used to produce classes which allow dealing with concrete objects in a fashion that reduces them to their abstract components.

    In the domain of computer science, other techniques such as the use of graphs and other data structures are another way of providing abstraction for various underlying 'things', which even though they may not look anything like the graphs (or the matrices or other structures) have some of their essential characteristics embodied in these structures.

    In other domains, abstraction can be achieved in very diverse fashion, such as the never ending classification process at work in the human brains, which creates and maintains "prototypes" (high level invariant representations) representing everyday concepts.