in reply to "Accessors break encapsulation"?

It is the practice not the concept breaks encapsulation.

As a concept, getter/setter does not break one thing. Your object needs some way to communicate and interact with its surrounding, doesn't matter whether you call that communication channel getter/setter or mouth/ear, you cannot avoid it.

If the programmer provides unsafe access to an object through getter/setter, it is the programmer's problem, because the programmer abuses the concept and doesn't use it wisely.

If we are only talking about Perl, then seems to me the real problem is that, on one hand, Perl tries to provide you a way to nicely packaging your modules, on the other hand, it is the nature of the language that provides ways to break what it tries to protect, however you can also call that freedom, just like any other such things in one's daily life.

Replies are listed 'Best First'.
Re^2: "Accessors break encapsulation"?
by jplindstrom (Monsignor) on Jul 20, 2005 at 09:28 UTC