Code reviews are essential in any development life cycle. Imagine if we all just wrote code, test it and publish or compile it and send it off to it's merry way. Unfortunately if you are a developer and you think you don't need to have someone take a peek at your code, you are really missing out. I've heard some developers say that they don't want to have someone else look at their code because it's theirs. Some are embarrassed because they are still using old 'for' loops and some may think that its time to get criticized for your mistakes. Sometimes we need to think of a code review as a point in the process where a group of people can come together and attempt to make a piece of software or a website better. By the way, don't be embarrassed if you use 'for' loops.
An Essential Tool
I make code reviews an essential part of my development process. A company that truly believes in it will make it part of their program management and not bypass it. Its important to understand the qualitative elements and processes involved in development. The more we can implement a standard practice of using a qualitative approach to code reviews, the chances of a successful software project increases dramatically. So what is the ultimate goal of a code review? By gathering knowledge from other developers, we can create a better product.
Approach to code reviews
The approach that I take on a software project is the same on each one of them. The code review is important, its pivotal and it can make a difference in somebody's day, so its important to make it a practice to be positive. If a manager or team member making negative comments about your code its easy just to want to walk out or quit, but don't do that.
Things you can do if you are involved in a code review:
- Give positive feedback
- Don't talk down to a team member
- If you critique somebody's code, offer a solution. If you don't have a solution then say you see an opportunity but aren't sure how to handle it. Somebody on the team may be able to identify a solution or object to it.
- Show some compassion
Things you can do if you are the one being reviewed:
- Don't take criticism as a personal attack
- Allow time for a team member to respond to a review topic
Productivity in code reviews
Code reviews are much more than a meeting of professionals critiquing ones code. It should be commonplace that code reviews have a supported culture of improving and enhancing a product or service. It doesn't matter how many pages or classes of code that get reviewed as much as how many "real" problems the review solves. I emphasis real because some suggested solutions may not have a real problem connected to it. Its necessary that a solution be associated and correlated to a specific problem.
If you run the Agile or Scrum methodology of project management then be sure to include a separate iteration for code reviews. The earlier in the process a defect can be found the better as it can get costly if a bug is found in production that could have been mitigated in development.
When to have code reviews
While it's not necessary to have code reviews for small changes, sometimes it's a good idea to start thinking about the frequency of code reviews for certain projects. I tend to not have code reviews where the change does not alter the functionality or structure of the software product.
I use git for all of my code reviews. Back in the day we just huddled in a conference room and read the code line for line. That took a lot of time and seemed like it was not very productive. With more usage of Git and other source control tools, we can collaborate online. GIT related source control is decentralized, meaning everybody has there own copy/version and pushes/pulls to the same location.
First, we start off by giving access to our Git project. Developer A will clone project123 and creates a new branch to work on. Only developer A will see these changes until the commit to the remote repository is made. A Pull Request will need to be made and approved by the projects maintainer. If the maintainer has questions or comments they can clone the branch that developer A had committed and make changes and provide feedback. When all is good, the changes are merged into the remote repository.
Code reviews are a necessity in software / web development. They not only offer an advantage of enhancing a products quality, they also help build a culture of support. Whether your an agency or a individual freelancer, or a software engineer with 25 years experience it's a must have in the tool belt.