From the course: Software Design: Code and Design Smells

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Encapsulation misunderstandings

Encapsulation misunderstandings

From the course: Software Design: Code and Design Smells

Start my 1-month free trial

Encapsulation misunderstandings

- [Instructor] Encapsulation compartmentalizes the elements of an abstraction, separating the interface from implementation. This means that design smells in this category are going to be dealing with the accessibility or protection of abstraction members. Let's start off with our first of three encapsulation smells with deficient encapsulation, which happens when an abstraction's implementation and/or members are exposed or poorly protected. This leads to data vulnerability and behavior misuse. For instance, allowing a class's internal state to be accessed outside the class would be a red flag, as you'd only want that data to be changed from inside the class itself. The solution here is to ensure that your abstractions are only as accessible as they need to be, and their members are properly protected. Closely related to deficient encapsulation is unrestrained encapsulation, which you can think of as a more severe case of…

Contents