January 2022
Beginner to intermediate
416 pages
10h 21m
English
The first of the three main tenets of object-oriented programming is encapsulation. This word might conjure up an image of a space capsule, a cell wall, or a medicine gelcap, where the precious cargo inside is protected from the outside environment. In programming, encapsulation has a similar but even more detailed meaning: hiding internal details of state and behavior from any external code and having all code in one place.
In this chapter, we’ll see how encapsulation works with functions, then with methods of objects. I’ll discuss different interpretations of encapsulation: using direct access versus using getters and setters. ...