From the course: Programming Foundations: Conducting Code Reviews

Understand the author’s purpose

From the course: Programming Foundations: Conducting Code Reviews

Start my 1-month free trial

Understand the author’s purpose

- [Instructor] Before reviewing another developer's code, it's important to understand the overall goal of the code changes. When code is put up for review, it usually has some description associated with it that describes the purpose of the code changes. To ensure the code changes work as expected and do not cause any unintended side effects, it's essential to understand the purpose of the code changes, what the code changes are meant to do for the application. In the case of adding a new feature, you should understand what new functionality should be expected with these code changes, as well as what should remain unchanged. For example, let's say your code adds a score component to a video game. If the player hits an obstacle, should the score go down? Should the score drop to zero? Should the score stay the same and that's the score for the users turn ending the round? Understanding how the new code and the overall feature fits into your application is key. You have to understand what the author is trying to do if you want to review and test their code. If a bug is being fixed in a code change, it's important to understand what the bug is in the first place, and how to recreate it with your current application. Let's say certain letters and characters such as emojis or accented characters are not encoded properly when you name your player in an iOS game. You can test this by creating a name with accented characters, and see the fact that the name does not look as expected in the application. With knowledge of this error, you can run the new version of the code and see if the error still exists. For code changes that delete code, you should understand what types of files are being deleted, and why they're being deleted. This will help you ensure the deletion does not affect anything else in your code base. If the author's intent is unclear and you're not sure what code changes are being made or why, you can always send a message or meet up with the author to discuss the intent of the code changes. As a reviewer, you have to understand what the code changes are and why they are being done, so that you can review appropriately. By understanding the author's intent, you can ensure the code changes do exactly what they're supposed to do. If you find a bug was not fixed in a certain case, or a piece of functionality was left out, you can always make suggestions to the author to cover these cases. That's your job as a reviewer, to ensure the code changes do what they are intended to do, and make suggestions when they do not modify the application as expected.

Contents