Another controversial question
Another controversial question
- Subject: Another controversial question
- From: Drew McCormack <email@hidden>
- Date: Sun, 2 Sep 2001 08:16:45 -0700
Can anyone tell me why key-value coding is not a serious violation of
encapsulation, and therefore also a violation of object-oriented
principles?
Everyone took a shot at me for suggesting that inheritance of
constructors was not such a good idea. The general feeling seemed to be
that if you didn't inherit constructors, you were violating an important
aspect of OO.
Yet, when I see key-value coding, it scares me to death. Maybe I have
missed the point, but it seems this is a way of changing the internal
state of an object by bypassing the accessor methods provided. This, of
course, defeats the purpose of having accessor methods in the first
place, which is to introduce indirection such that the implementation
of a class can change independent of its interface.
Can any experienced Cocoa programmers out there tell me if they use
key-value coding, and if so, under what circumstances? I can certainly
see that it makes coding much easier, but it also seems to introduce
stronger coupling between classes, which is generally undesirable.
I'm not trying to start trouble here, but I would like to understand the
reasoning behind it more fully.
Drew McCormack