On Tue, Apr 28, 2009 at 5:15 PM, Jerry Krinock <je...@ieee.org> wrote:
> If Melissa is referring to a managed property, if it is non-transient, then
> yes this could be used in the predicate of a Core Data fetch.  The
> disadvantage is that now every object in every store has this redundant
> (derived) attribute.  More important than the wasted bits is that custom
> setters are now required to keep the derived attribute in sync with its
> source attribute, opening a way to introduce bugs into future versions.

We all love normalization.  That is, until it hinders our progress.

One of the things to keep in mind with Core Data is that you are *not*
using an RDMBS.  Sure, one might provide the backing storage under the
hood, but the traditional concern with data normalization in an n-tier
enterprise situation is with the data: the data must remain pure and
accessible to any number of interfaces.

Core Data is different: it's an object graph management framework for
desktop apps.  You are required by its very nature to couple the
business logic much tighter to the data storage, since you really are
storing business-logic-bearing model objects.

So step 1 is to stop clinging to normalization rules.  (My database
professor would kill me for that sentence, but it's true.)  There
really is no redundancy here, because the data stored on disk is never
really separated from the model objects which use that data.  In an
n-tier app, you would be correct to avoid storing the derived
property.

As for the logic required to maintain this relationship, that's why we
have KVC/KVO!  Implement +keyPathsForValuesAffectingValueFor<Key>: as
appropriate.  Implement your KVC setters/getters for the independent
attributes such that they invoke -setPrimitiveValue:forKey: for the
required dependent properties.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to