Card 08/ 08

RecapDifficulty: Advanced1 min

What Is Hidden, From Whom, and What Still Leaks

Five things this topic established, and where each one was.

What the topic established, and which card it was on
The thingWhere
private reduces the number of places a rule has to be written to oneKeeping a Field Where Only Its Owner Can Reach It
Four access levels, and the widest of the two middle ones is protectedThe Four Access Levels
private protects the variable and not the object it points atWhy Your private List Is Not private
Copy on the way in as well as on the way outWhy the Same Leak Happens Through a Constructor
extends exposes the whole parent; a field exposes what you choseHas-a Against Is-a

Hiding a variable is easy and hiding an object takes a copy. A class whose fields are all immutable values is encapsulated the moment they are private; a class holding collections is not, until something stops the references escaping.