Re: Using properties (was Re: Outlets / IBOutlet declarations)
Re: Using properties (was Re: Outlets / IBOutlet declarations)
- Subject: Re: Using properties (was Re: Outlets / IBOutlet declarations)
- From: "Michael Ash" <email@hidden>
- Date: Thu, 20 Nov 2008 11:50:11 -0500
On Wed, Nov 19, 2008 at 11:53 PM, mmalcolm crawford <email@hidden> wrote:
>
> On Nov 19, 2008, at 8:40 PM, Michael Ash wrote:
>
>> On Wed, Nov 19, 2008 at 5:41 PM, mmalcolm crawford <email@hidden>
>> wrote:
>>>
>>> On Nov 19, 2008, at 2:29 PM, Michael Ash wrote:
>>>>
>>>> Because there's essentially no good way to dispose of properties given
>>>> the way that they're implemented.
>>>
>>> I'm not sure why this is the case?
>>> You send a release message to instance variables for which there is a
>>> corresponding retain or copy property.
>>
>> This does not qualify as "good" in my book. A fundamental of good
>> programming is "once and only once". You've now described the
>> semantics of these properties in two different places in your code
>> and, worse, one of those places is implicit rather than explicit.
>>
> I'm not sure what you mean here?
> There is only one place where the semantics are described: In the property
> declaration.
> Whether you release or not in dealloc is a corollary of that declaration.
Well, I think this is just a question of wording. It's true that it's
only described in one place, but you have to get it right in two
places. Whenever you have a situation like that and the compiler can't
check it (like in this case), then you have a potential to get mixed
up, especially if you make changes later on. It would be fairly easy
for the properties mechanism to provide a way to use the @property
declaration to generate the correct -dealloc behavior. In fact, there
is one, "self.whateverProperty = nil", it's just that this has other
unfortunate side effects. An alternate version with no side effects
would remove this deficiency.
> In which case we may be mostly in violet (sic) agreement.
> I obviously see significant benefits to using properties, and agree that
> their utility *might* be enhanced if they could also handle dealloc. I got
> the impression that others here were suggesting that they provide little or
> no benefit at all...
Yeah, I didn't get that impression myself. It's just a bit painful to
see such a construct when a small addition to it would have made a
significant improvement.
Mike
_______________________________________________
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