Re: release and reference counting query
Re: release and reference counting query
- Subject: Re: release and reference counting query
- From: Marc Stibane <email@hidden>
- Date: Tue, 18 Nov 2008 19:42:16 +0100
Am 17.11.2008 um 19:34 schrieb j o a r:
On Nov 17, 2008, at 10:02 AM, Marc Stibane wrote:
So why the local var?
3 lines of code instead of 1...
Isn't a main goal of Cocoa to write *less* code?
The main goal for most programmers is not to write less code, it's
to write maintainable code [*]. It just so happens that a smaller
body of code often also is easier to maintain. That said, writing
less code is also an often used obfuscation technique -> You need to
find the right balance.
An argument that I've often heard in favor of the use of temporary
local variables is that it makes it easier to inspect them in the
debugger,
sure - but only if you are concatenating functions or methods, passing
the result of one as argument to another.
In this case the result is just stored in an ivar, which can be
inspected like a local var.
and I think that's a pretty good point (although it doesn't really
apply in this case).
Right (both statements!).
Also keep in mind that in Cocoa we strongly advocate the consistent
use of accessor methods for instance variables.
Fine - but for the first initialization from inside the class? This
seems like being religious in spite of drawbacks...
If you don't like a particular piece of sample code,
Don't get me wrong - I am a long time Carbon programmer, and use Cocoa
since a few months.
I just wanted to know why it is better to write bloated code - maybe I
am just overlooking something because of my lacking background
knowledge of Cocoa.
I'd suggest that you file a bug report / enhancement request here:
<http://developer.apple.com/bugreporter/>
If nobody can tell me a compelling reason why this code is good I'll
do that.
[*] It has to be functional too, of course, but that kind of goes
without saying...
--
In a world without walls and fences,
who needs windows and gates?
_______________________________________________
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