Code Review is called the control of the written code by one or more people before it is taken inside. The main purpose of code review is to prevent bugs. Additionally, code reviews improve code quality and provide a common code arrangement on large projects.
Having a code review checklist will prevent common mistakes from occurring again. It also provides help for both people who writing the code and reviewing the code.
“Sometimes the developers might forget to check some things. A checklist will make the review process more consistent, as it will be a constant reminder of what should be reviewed.”
The following items such as naming, memory leak, performance, security, comments, documentation and etc. should be considered while writing code. Note that code review checklist items can be expanded according to software languages, projects and teams. In this article, I would like to summarize them by considering iOS development.
✔️ Check any conflicts in the PR.
✔️ Check the architecture of the new written code.
✔️ Naming is important for writing self-documenting code so it should be clear.
✔️ Bool values must begin with is, can, must, will…
✔️ Use PascalCase for types and protocols, camelCase for everything else.
✔️ Weak self should be used for closures
✔️ Delegates must be weak
✔️ Check for any retain cycles
✔️ You should write explanations, but avoid putting unnecessary comments.
✔️ Codes with comment lines should be deleted.
✔️ MARK should be used when necessary to describe an item.
✔️ Empty or unused functions, variables should be removed.
✔️ It is important to pay attention to line spacing, and to eliminate unnecessary spaces.
✔️ There should not be print in the code.
✔️ Make sure the public variable or function is private.
✔️ Final classes should be used with care.
✔️ Force unwrap should not be used. Instead of self!, self? or guard let should be used.
✔️ Instead of +, string concatenation should be performed with /().
✔️ Instead of == nil, isEmpty should be used.
✔️ Instead of == false, ! should be used.
✔️ guard let and if let should be used more often.
✔️ Check if all errors are handled
✔️ Documentation of code written for large projects is important. It helps to explain what your code is doing, why it’s written the way it is, and/or how to use it.
“There are many benefits to having your documentation in great shape. Three of the most significant advantages are: reduced development time for new features, fewer support requests from people using your code, and more people finding out about your business.
Remember that the comments for code review should be instructive in such a way that the developer can understand and correct them. And also, code reviews cannot be conducted by the person who wrote the code. The code should be reviewed by others.
“Also, a reviewer has ownership and responsibility over the code they are reviewing. They want to ensure that the codebase stays consistent, maintainable, and all of the other things mentioned in “What to look for in a code review.” ”
“Code review tools will keep your project free of bugs and errors ❌ Find the best one for your team with this guide 🚀 ”
In short, code review is a very effective and important method that speeds up the software development process, which is used to improve code quality, detect bugs and security vulnerabilities, and offer appropriate solutions. Again, I would like to point out that the general topics that I have mentioned above will definitely change in terms of each team and project.