How to become a better Code Reviewer - Part 2 : What does a Code Reviewer look for?
Tags: codenewbie, computerscience, csharp, java
Published: 2020-05-09 12:30:53

##**What Do Code Reviewers Look For?**
-------------

- **<h3><strong>Design:</strong></h3>**

So what do i mean by design? I refer to design by the overall design of the change list.

1) Check whether all the interactions of code in the change list make sense to you. 
2) Check whether the change is from library or the actual codebase.
3) Check whether it integrates well with rest of the system.
4) And also make sure whether it is a good time to add this functionality.

------------------

- **<h3><strong>Functionality:</strong></h3>**

1) Check whether the author of the code have done what he/she was intended to do based on the change list. 
2) Think in terms of the end-users and also the developers who is going to use this code in future .

<img src="https://media1.tenor.com/images/4890e6d67ba60228505ed91c6d51d424/tenor.gif?itemid=16542478" width="4096" />

3) Think about the edge cases , looking for concurrency problems , and making sure that there are no bugs that you see just by looking at the code.
4) If you don't have any idea about what is going on , you can have the developer/author of the code to give you a <b>demo of the functionality</b> before going through the code.
5) If any kind of <b>parallel programming</b> is going on in the change list make sure there are no deadlocks or race conditions

------------------

- **<h3><strong>Code Complexity:</strong></h3>**

<img src="https://media1.tenor.com/images/a6c2b8c3685b4cf01841f2a34c7a5c68/tenor.gif?itemid=13330243" width="4096" />

1) If the author of the code approached more complex way and also in a way it can't be understood quickly then it means that he/she is likely to introduce bugs when they try to modify this code in future.
2) <b>Generics</b> are good but not always. A developer should know when it is likely to be approached using generics and when not to.

------------------

- **<h3><strong>Unit Testing:</strong></h3>**

1) Never approve a pull request that doesn't have corresponding unit test, integration, or end-to-end test. In general , tests should be added in the same change list
<img src="https://media1.tenor.com/images/9c077f58ddad4b19543a9fed0ff057db/tenor.gif?itemid=4607935" width="4096"/>
2) Check whether tests actually fail when the code is broken , do they make simple and useful assertions , are they separated appropriately between test methods.
3) Tests are equal importance as of to the actual code base , so check for complexity in unit test as well.

------------------

- **<h3><strong>Naming:</strong></h3>**

A valid name is enough to fully communicate what the actual functionality is.

1) Check whether the author of the code uses good/valid name for everything . It can be variable, method,class declaration literally everything.

------------------

- **<h3><strong>Comments:</strong></h3>**

Comments are useful when they explain why some code exists and it should not be a place where to explain everything the code is doing. If the code isn't clear enough to explain itself , then it should be made simpler.

1) Check whether there are clear comments and also whether those comments are actually necessary.

------------------

- **<h3><strong>Documentation:</strong></h3>**

<img src="https://media.tenor.com/images/562eb8bd6d07427af8d599df8d1319d6/tenor.gif" width="4096" />

1) Ask for documentation from the author of the code and also ask them to update associated documentation for the code change that they made
2) Also consider whether a part of the documentation need to be deleted or so, when the particular functionality is removed.

------------------

**<h3><strong>Congratulations:</strong></h3>**

<img src="https://media.tenor.com/images/53283745e90e50795b5ab1bf26841a88/tenor.gif" width="4096"/>


-----------------
### **Next Steps:**

{% link https://dev.to/divakarkumar/how-to-become-a-better-code-reviewer-part-3-how-to-write-code-review-comments-80b %}



Banner Image Courtesy : <a href="https://www.freepik.com/free-photos-vectors/business">Business vector created by freepik - </a><a href="http://www.freepik.com">www.freepik.com</a>