Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

slooksterPSV

macrumors 68040
Apr 17, 2004
3,544
306
Nowheresville
caveman_uk said:
Yes you can declare variables just when you need them...this isn't pascal;) You just can't declare a variable in a 'for ( blah; blah; blah)'
Oh ok, that still sucks. But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
slooksterPSV said:
But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
You can name your own variables and methods almost anything you want, however the setter/getter methods for variables should follow a certain syntax if you want to use them with Cocoa Bindings. The Cocoa APIs tend to be verbose in their method signatures, but that can be seen as a strength as well. Try going back to a piece of code you haven't looked at after 6 or 12 months. Would you rather try to figure out "arrayWithString" or "strarr"?
 

gekko513

macrumors 603
Oct 16, 2003
6,301
1
slooksterPSV said:
Oh ok, that still sucks. But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
Then you haven't been working much with large programs. The more I work with and maintain large programs the more I recognise the need to use variable and method names that are as describing as possible. Readable Objective C methods with named parameters are a definite advantage when working with unfamiliar code.

Code completion can solve most of the problems with the tediousness of using verbose symbol names, but I'm not quite satisfied with Xcodes code completion. I like Netbeans better.

I agree that not being able to declare the loop variable within the for loop itself is the most annoying thing about Objective C. It drives me crazy. :mad:
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
slooksterPSV said:
Oh ok, that still sucks. But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
It's a pain if you do have to type it but that's why you have code completion turned on;)

I think longer, more descriptive names adds to code readability and that can only be a good thing (I was taught that it was a good thing 20 years ago and I doubt opinion has changed much). Objective-C itself couldn't give a monkey's what you call things but the implementation of Cocoa expects certain things. For example if you're using key-value coding Cocoa expects that the setter for a variable is called 'setVariableName' and the getter is called 'variableName'.

So go ahead and call your variables x1 and q but if anyone ever has to change your code in the future I think their defense lawyer has a mitigating factor when that coder hunts you down in revenge...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.