Encapsulation means that you should think of each class as a machine that provides a service. For example, a chair allows you to sit on it, or a lawn mower allows you to cut your lawn.
private methods relate to the internal operation of the machine. In contrast, public methods relate to how you (other classes) interact with the machine.
Example One: Chair ...
When you are sitting on a chair, you do not need to know the amount of filling or the amount of paperclip, you basically need to know whether it is busy or not, and if it is stable.
- Public Methods: IsStable, IsOccupied, Sit
- Private Methods: CalculateStuffingVolume, CountNumberOfStaples
Example Two: Lawn Mower ...
, ( ), .
- : GetFuelLevel, IsBladesSharp, TurnOn, TurnOff
- : Combust .. , .
:
, , , ...
: . , . . ,
: .GetFuelLevel, ., ., .
uphosltry, , . , . , , . , Person Lawnmower.Combust(), .