Re: Design Question: Pro & Cons of KVC/KVO
Re: Design Question: Pro & Cons of KVC/KVO
- Subject: Re: Design Question: Pro & Cons of KVC/KVO
- From: Ken Thomases <email@hidden>
- Date: Thu, 21 Aug 2008 18:25:44 -0500
Remember that NeXT and Apple didn't just invent KVC, KVO, and Bindings
out of thin air for no better reason than they were enamored of the
idea.
There was a substantial history of NeXTStep/OpenStep/Cocoa programs
written. The developers at NeXT and then Apple recognized that there
was a large body of repeated design elements and implementations for
some very common tasks. Gradually they extracted these commonalities,
generalized them, and implemented them in a way intended to allow the
elimination of all (or most) of those previous custom implementations.
In other words, there's a reason that the design you came up with on
your own is so similar to what KVO actually does. It's because Apple
has seen such designs before many, many times -- I'm sure they wrote
their own implementations many times for many programs and frameworks
-- and they eventually created KVO just so you (and they, and all of
us) would never have to implement that same thing over again.
The same with Bindings. Reading the Bindings guide actually describes
the thought process behind this feature of the framework. Many, many
projects were filled with repetitive controller glue code for updating
views from models and vice versa. Apple figured out a way to write a
feature into the frameworks to eliminate a huge amount of that
repetitive glue code.
So, while there's no rule that you have to use KVC, KVO, or Bindings
in your own code, chances are good that you'll just end up reinventing
them badly. If it weren't highly probable that you'd do that, then
KVC, KVO, and Bindings wouldn't exist.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden