From the course: Programming Foundations: Conducting Code Reviews
What is a code review?
From the course: Programming Foundations: Conducting Code Reviews
What is a code review?
- [Instructor] A code review is a methodical review of proposed changes to a software source code. The proposed changes might consist of something as simple as changing the text on a website. It could also be more challenging, such as adding an API call to a new back-end service or adding push notifications to the product. In other cases, it could be more of a refactoring of code, changing the way something is written in the code but not changing the functionality. Let's walk through an example of how the code review process works. We'll be going through many of the things brought up here later in the course, but I find a brief overview can be useful. Let's say a software developer has been tasked to change the text in a heading shown on a website. When the developer is ready to make changes, they'll pull down a copy of the current code base and change the appropriate text. In this case, let's say the developer changes the text within an h3 tag in an HTML file. When the developer or author is finished making their changes, they'll create a request for others on the team to review their changes. There are applications and websites that help with this process, allowing you to easily create this request and see the suggested code changes, but we'll get into that later. Once the request has been submitted, others on the team will review the code and give suggestions on how to improve it. Things that code reviewers look for can be narrowed down into a few categories. First, the reviewer must make sure that the suggested code changes match the author's or software developer's intent. In other words, did the author change the right heading and did the author change it to the right thing? The reviewer could also investigate whether there is a more efficient way to accomplish the given task. Did the author hard-code the new piece of text or was it supposed to be read from and changed in a different file? This type of reviewer is looking at implementation details, how the change was implemented or written in the code. The reviewer could also look at if the code is readable, is the code easy to understand so that if it had to be changed again, another software developer can jump in and easily figure it out. The code reviewer should also think about if this change is maintainable, as well as if it breaks any design patterns previously established in the code base. Once a reviewer has finished reviewing code, they'll give suggestions to the original author about how they can iterate on their changes. The original author can use the suggested changes or discuss with the reviewer if there's confusion or disagreement. Once the author and reviewer agree on the proposed code changes, the reviewer approves the changes and the changes get integrated or merged officially with the code base. That's how code reviews work in a nutshell. Unlike many other practices, code reviews can accelerate and streamline the process of software development. Although automated solutions do exist, there's nothing as good as having another software developer review your code.