4 ms·
That's correct: here's the passage in question from the Google Objective-C style guide: > dealloc should process instance variables in the same order the @inte
by objclxt 14y ago
That's correct: here's the passage in question from the Google Objective-C style guide:
> dealloc should process instance variables in the same order the @interface declares them, so it is easier for a reviewer to verify.
One engineers idea of 'logical order' may not be another's, so alphabetical order seems as good a sorting method as any. And since the article itself doesn't link to the style guide, here it is:
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml http://google-styleguide.googlecode.com/svn/trunk/objcguide....
Google keep it regularly updated, so it includes newer developments like ARC and the modern literal syntax.
- scrumper 14y agoThe style guide (in that link at least) doesn't actually enforce or even mention alphabetical order for ivars. It seems an unusually proscriptive restriction for what's quite a reasonable style guide. The stated restriction - dealloc in declaration order - makes a lot of sense. (Also, line lengths merely have to 'try' to be less than 80 characters, so there's wiggle room here too.)
- packetslave 14y agoNote that the public style guides aren't always a 1:1 match with the internal ones, usually for legacy reasons or to be more consistent with other internal languages. I don't see anything offhand in the internal ObjC guide about alphabetical order for ivars, so it's possible the OP misunderstood the "dealloc in declaration order" rule. It's also possible his specific project had a convention of sorting them alphabetically.
- tazzy531 14y agoAlso different teams have slight variations from the official style guide.
- blueprint 14y ago'Logical' may indeed be an insufficient description given that it lacks any inherent substance (logic can demonstrate something which is true or false). Personally I generally organize by kind: model (including state), and then interface (views, etc), and then controllers (including helpers).