Design patterns·Objects, messages and the principles
every field is private with a public pair of methods around it, which is the same as public with more typing.
Getters and setters
Also calledaccessors, accessor methods, property accessors
Methods that read and write a field, generated by habit in most object-oriented codebases. A getter that simply exposes a field and a setter that simply assigns one provide no hiding at all; they only preserve the ability to add behaviour later, which is worth something but far less than the ceremony suggests. A blanket set of them is the surest sign of an anaemic domain model, because it means the behaviour that should be inside the object is somewhere else.