site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com In my opinion, whichever is more readable. In this case the second. On Mar 31, 2005, at 1:19 PM, Adam wrote: Is it better to be more clear like and break things down: This email sent to lists@johnbrownlow.com -- John Brownlow Deep Fried Films, Inc http://www.johnbrownlow.com http://www.pinkheadedbug.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... But the readability is compromised by using shorthand iVar names like 'nc'. 'defaultNotificationCenter' is way better. In terms of execution time I think the difference is nil, or literally a few nanoseconds. Often it will turn out to be faster because you will re-use the variable further down in the code and save a messaging round. I've lost count of the number of times I've written a long line like your first, thinking it was easier, only to find out an hour later that I had to do the same thing several times, so went back and broke it down into assignments and variables. What is considered good cocoa style? I am sometimes tempted to be efficient and code like: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendCommandToSocket:) name:@"AGFIBSSendCommandToSocket" object:nil]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(sendCommandToSocket:) name:@"AGFIBSSendCommandToSocket" object:nil]; _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/ lists%40johnbrownlow.com This email sent to site_archiver@lists.apple.com
participants (1)
-
John Brownlow