On Oct 6, 2011, at 17:12 , Charles Srstka wrote:

> But isn't creating a whole abstract superclass for this a lot more of a 
> hassle than just making a private property?

*Some* more. I'm not sure about a *lot* more.

> What would you get from that approach that you wouldn’t get from just having 
> the getters and setters for a property “foo” call through to the synthesized 
> accessors for a private property “privateFoo”?

Functionally, they're pretty similar, I guess -- one property uses another in 
both cases.

The only real experience I have with a dual-property approach is via Core Data 
(foo vs primitiveFoo -- imagine we're trying to put a 'setNeedsDisplay:' in a 
Core Data property override, so that we need to call through to primitiveFoo). 
It seems straightforward enough conceptually, but when you try to use it, 
things get hard.

Now if you find other functionality to add to the property, you have to ask 
yourself whether you're modifying the primitive property or the public 
property. Often, the answer is "Duh, I dunno." KVO can get tricky, because the 
notifications start to go round in circles or just break, and it's not clear 
how to fix the problem. You start having to guess how having two more or less 
identical properties interact with (say) undo. If you start subclassing, you 
again may have puzzling decisions about how and where to add overriding 
behavior.

I don't say it can't be done. I'm just saying when I've tried it for real I've 
found myself in a classic Houdini bind (that is, handcuffed, chained and locked 
in a steamer trunk at the bottom of a river) without actual Houdini skills to 
get me out.

But maybe that's just me.


_______________________________________________

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