Steinar,
you missed my point. I explicitly said not to get bogged down in my
example. The point is that changing the internal details of your class
shouldn’t result in your users being forced to change their code. As I
said, exposing your implementation tightly couples your code and your
users. As Matthew
pointed out, you shouldn’t have sets and gets for every item in your
class. You should have a clearly thought out api that isn’t tied to the
internal detail. Exposing internal, either through making data public or
blindly creating gets and sets for private data members is just bad
OO design.
An addition to my example that makes things little cleared would be a
subclass that validated the words you could use. With a public variable
I couldn’t enforce that, but I could override my setter to add
validation.