Every day more and more people become developers. Of course, iOS development is a trend now. Common sense in programming says that we should write readable code. The code we leave should be easily understandable and supportable by each and every programmer.
1. The first important thing is the Code Style
![](https://cactus-now.com/wp-content/uploads/2019/10/iOS-Best-Practice-6-1024x768.jpg)
Start from Code Style
I started with Objective-C.
At the moment, fewer and fewer 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 have been able to fit readable horizontal lines.
![](https://cactus-now.com/wp-content/uploads/2019/10/iOS-Best-Practice1-1024x768.jpg)
Use the ternary operator only for a single condition. Don’t stretch it over 2 or more conditions.
Add a space after the scope in the method signature.
![](https://cactus-now.com/wp-content/uploads/2019/10/iOS-Best-Practice-2-1024x768.jpg)
Naming: Don’t spare letters but do use distinct names.
Create Category for strong segmented functionality.
Write code that is easy to understand.
![](https://cactus-now.com/wp-content/uploads/2019/10/iOS-Best-Practice-3.docx-1024x768.jpg)
Comments, in my mind, are unnecessary. Decompose code into small, separate modules each with a single responsibility.
Use literals when you work with collections.
Collect all global values in a Constants file.
![](https://cactus-now.com/wp-content/uploads/2019/10/iOS-Best-Practice-4-1024x768.jpg)
Use Boolean variables reasonably.
Monitor the list of imports, and do not overload the code with surpluses.
![](https://cactus-now.com/wp-content/uploads/2019/10/iOS-Best-Practice-5-1024x768.jpg)
Of course, this isn’t anything new in code style, but just a collection of the best advice.
Continue reading: iOS Best Practices. Part 2: Swift Code Style > > >
![Maxim Vialyx](https://cactus-now.com/wp-content/uploads/2018/01/Cactus2600.jpg)
Maxim Vialykh is CactusSoft iOS Tech Lead.
Technical Background
Programming languages: Swift, Objective-C, Java
Technologies and Platforms: iOS, Android, Windows Phone, Amazon S3, Google Cloud, Google APIs, Facebook APIs
Frameworks: PhoneGap, Xamarin
Tools: Invision, SVN, Git, PhoneGap, Titanium, Xamarin, Sketch, xCode, IntelliJ IDEA