jargon

Comparison

Getters and settersvsInformation hiding

Getters and setters

every field is private with a public pair of methods around it, which is the same as public with more typing.

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.

Full entry →

Information hiding

the thing most likely to change is the only thing behind the interface, and nobody outside can name it.

Parnas's original criterion for decomposing a system: each module hides one decision that is likely to change, so the change stays inside it. It predates encapsulation as a language feature and is a stronger idea than it — private fields hide data, information hiding hides a decision. The test is not whether the fields are private but whether you could change the decision without editing anything outside the module.

Full entry →

Related comparisons