The principle of encapsulation advocates separation of concerns and information hiding. Hiding implementation details and hiding variations are two techniques that enable the effective application of the principle of encapsulation. This chapter discusses the principle of encapsulation and these enabling techniques, and provides a detailed description of the following design smells that result from the violation of the principle of encapsulation: Deficient Encapsulation, Leaky Encapsulation, Missing Encapsulation, and Unexploited Encapsulation.
The principle of encapsulation advocates separation of concerns and information hiding through techniques such as hiding implementation details of abstractions and hiding variations.
Table 4.1
Design Smells and the Violated Encapsulation Enabling Techniques
Design Smells | Violated Enabling Technique |
Deficient Encapsulation (Section 4.1), Leaky Encapsulation (Section 4.2) | Hide implementation details |
Missing Encapsulation (Section 4.3), Unexploited Encapsulation (Section 4.4) | Hide variations |