Coding Standard For iOS

Coding Standard For iOS

All code has to be commented 

1.In iOS, methods are created in .m file. Adding Proper comments in the file before any methods is a good practice. Prefer detailed commenting of code (Similar to Fig: 1.0) including purpose of variable used, another method calling, etc. so that non technical person can easily review and understand the code. 

2.When I do class level commenting, will add some description about functionality of that class in commenting as well. I am not saying to enter too much descriptive but short one which provides basic functional idea of that class. 

3.Follow the same for method level commenting as well. Also if I pass parameters to method then provide description of that parameters as well (Similar to Fig 1.2). 

4.Use common files for repeated function used in different classes. 

5.All swift code must always compile without or less warnings. 

6.If you are sending a message with a particular long name, break it up into multiple lines. 

7.Follows "ANSI style" for brackets, with opening bracket in a separate line. 

8.Follow the Camel Casing. Means variable name should start with small letters and capitalize the first letter of embedded words. 

9.Use design patterns when needed (such as use of Singleton class, following MVC pattern).

10.Focused on better UI and UX.

11.Will call the web services in asynchronous manner, so

that UI do not hang.

12.Prefer using the BLOCKS as many as possible to make

the application smoother.

13.Use Cocoa Pods for including third party framework.

14.Never use hard coded (static) path/drive/string name in a code.

15.Avoid having large files. If a single file has more than 1000 LOC, it is good to do refactoring of the code.

16.Intials of class name should be always in Capital letters (See Folder Structure below). 

17.Folder structure will be similar to below Fig 1.9. If you create any model class

then create a folder named Model & put all model class inside that folder. 

To view or add a comment, sign in

More articles by Janakkumar T.

Insights from the community

Others also viewed

Explore topics