Model: Encapsulation vs Information hiding

January 31st, 2021

 

often used interchangeably but actually refer to two separate, and largely orthogonal, qualities

 

 

Encapsulation

behavior of an object can only be affected through its API

  • reduces dependencies

 

Information hiding

Conceals how an object implements its functionality

  • work at higher level abstraction

 

Aliasing

break encapsulation by sharing references to mutable objects

  • increases dependencies

accidental aliasing can couple unrelated parts of a system

 

(src: Book: Growing Object Oriented Software, Guided By Tests - Steve Freeman & Nat Pryce)