Re: Only One Reason to ever use Transient Properties in Core Data
Re: Only One Reason to ever use Transient Properties in Core Data
- Subject: Re: Only One Reason to ever use Transient Properties in Core Data
- From: Jerry Krinock <email@hidden>
- Date: Wed, 20 May 2009 22:09:19 -0700
On 2009 May 20, at 18:45, Kyle Sluder wrote:
Your desire for hard and fast rules disturbs me. There are not
distinct use cases for every technology. Transient properties are
useful for certain things, often as a component of some larger trade-
off.
Thanks, Kyle. I'm trying to identify the tradeoffs.
On 2009 May 20, at 19:02, Sean McBride wrote:
In my app, I use some transient attributes to store attributes that
take many MB. That's a substantial savings not to store them on disk.
Ah, good.
Conclusion:
Don't just make an attribute "transient" because it can be derived
from other persistent attributes. Consider ...
the advantages of making an attribute "transient":
1. For a nonstandard data type, to avoid having to write a custom
accessor.
2. If its typical data size is huge, MB -- to save disk space.
3. Not having to clear its value when the document is reloaded, if
that is required.
and ... the disadvantages:
1. You cannot fetch using a predicate based on transient properties.
(Although I've found that this may work with the XML store.)
2. You cannot sort on transient properties using the SQLite store.
3. With transformable attributes you specify just one attribute and
the conversion is handled automatically. In contrast, with transient
properties you specify two attributes and you have to write code to
perform the conversion.
4. If you use refreshObject:mergeChanges: with the mergeChanges flag
YES, then any transient properties are restored to their pre-refresh
value after awakeFromFetch is invoked. This means that, if you have a
transient property with a value that depends on a property that is
refreshed, the transient value may become out of sync.
5. You may not get any warnings when you violate 1, 2 or 4. Things
"just won't work". Having things break when switching from XML to
SQLite stores is particularly annoying.
_______________________________________________
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