Getter/setter methods sometimes considered harmful

Mark Hooijkaas, $Revision: 1.1 $, $Date: 2004/10/02 10:10:55 $

Getter and setter methods are common practice in Java. They certainly have their uses and some reflection mechanism (e.g. hibernate and beans) make interesting use of getter and setter methods. However, it sometimes seems a dogma to always use getter and setter methods and make all fields always private. This article discusses situations in which it seems better to just use plain public fields, just as in the good old C struct. It will also discuss possible implications of such choice maintainability and future changes of access policy to the variable.