iOS Best Practices. Part 1: Objective-C Code Style
Every day more and more people become developers.
Of course, iOS development is a trend now:).
The common sense in programming is that we should write readable code. After us, the code we left should be easily understandable and supportable by each and every programmer.
1. The first important thing is Code Style
I started with Objective-C.
At the moment, less and less projects use this language, but let’s go through the style for Objective-C.
Do not stretch the code vertically — for a long time monitors are able to fit readable horizontal lines.
Use ternary operator only for a single condition, don’t stretch for 2 and more conditions.
Add space after the scope in method signature.
Naming: Don’t spare letters and use distinct names.
Create Category for strong segmented functionality.
Write the code that is easy to understand.
Comments, in my mind, are unnecessary. Decompose code into small separated modules with single responsibility.
Use literals when you work with collections.
Collect all global values in Constants file.
Use boolean variables reasonably.
Monitor the list of imports, do not overload the code with surpluses.
Of course, it isn’t something new in code style, just a collection of best pieces of advice.
To be continued…