• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Another controversial question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Another controversial question
      • From: Alykhan Jetha <email@hidden>
  • Prev by Date: Re: Writing a file type
  • Next by Date: Re: Drawing to the screen
  • Previous by thread: Re: Writing a file type
  • Next by thread: Re: Another controversial question
  • Index(es):
    • Date
    • Thread