Re: [ANN] Cocoa Style for ObjC: 1 and 2
Re: [ANN] Cocoa Style for ObjC: 1 and 2
- Subject: Re: [ANN] Cocoa Style for ObjC: 1 and 2
- From: Scott Stevenson <email@hidden>
- Date: Tue, 26 Oct 2004 17:40:04 -0700
On Oct 26, 2004, at 4:50 PM, Marco Scheurer wrote:
Here are two more naming conventions that I find useful:
- Naming observer selectors after the notification name. For instance
if I register to receive the notification named
'NSTaskDidTerminateNotification', the selector will be
@selector(taskDidTerminate:)
Yes, good one.
- Using 'each' in enumerations has the advantage of avoiding
collisions with other frequent variable names (and I prefer 'each' to
'one', could also be applied to other loops), for instance,
NSEnumerator *nameEnumerator = [allNames objectEnumerator];
NSString *eachName;
while (eachName = [nameEnumerator nextObject]) {
...
I would argue against this because "each" (in English context, anyway)
isn't free-standing. It has an implicit relationship with the many. In
other words, this looks weird to me:
[array addObject: eachName];
It reads as "add each name to the array" which isn't what it's doing.
Maybe even "currentName" would be better, as it would say "add the
current name to the array":
[array addObject: currentName];
But this is really nitpicking.
Programmers on other platforms are probably wondering how we have time
to think about this stuff. :)
- Scott
--
http://treehouseideas.com/
http://theobroma.treehouseideas.com/ [blog]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden