Re: Accessors
Re: Accessors
- Subject: Re: Accessors
- From: Chris Ridd <email@hidden>
- Date: Thu, 08 Aug 2002 12:44:08 +0100
Bill Cheeseman <email@hidden> wrote:
>
on 02-08-08 2:03 AM, Shawn Erickson at email@hidden wrote:
>
>
> - setSomeName: (SomeType*)newSomeName
>
> {
>
> if (newSomeName == _someName) return;
>
> [_someName release];
>
> _someName = [newSomeName copy];
>
> }
>
>
I've noticed a couple of people testing for equality and returning in the
>
first line, like this. My usual practice is to test for inequality, then
>
fall through to the bottom if the test is false.
>
>
Is there some advantage to the return? I've always thought it was just a
>
matter of style.
Style - it doesn't distract from the guts of the method, and it avoids a
level of indentation which you'd need if you did the "fall-through to the
bottom". It does violate a principle of only having one exit point per
method however, though to an extent that's just style too.
In such a short and simple method it isn't really worth it.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.