Skip to main content

Pro Tip: Most effective ways of writing clean code in iOS


Single Responsibility Principle

Single Responsibility Principle (SRP) is the first principle of Uncle Bob's SOLID principles. Each class, module or function should focus on just one thing. And do it correctly. This produces focused, simple and easy to read and understand code.

Don't repeat Yourself (DRY)

Avoid duplicated code. Reuse common code. This greatly improves code base maintainability and reduces new bug introduction or more places when making changes.

Use Meaningful names

This one is straight from the "Clean Code" book from our "Uncle Bob". Everyting is in the name. Use self-explanatory naming conventions for functions, classes or modules. This improves understanding the code base without having to dig deep into the implementation details.

Open-Closed Principle

Design code to be open for extension, but closed to modification. Use techniques such as inheritence, protocols and composition. This allows to introduce new functionality that will not change the existing.

Proper indentation and formatting

Follow the Swift-style guide and the codebase's common rules regarding the formatting and indentation. This helps the code base look more clean, consistent and readable.

Write unit tests

Implement Unit Tests to verify functionality correctness and to verify expectations.

Comments