<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CodeReview | Jacob Aloysious</title><link>https://jacobaloysious.in/tag/codereview/</link><atom:link href="https://jacobaloysious.in/tag/codereview/index.xml" rel="self" type="application/rss+xml"/><description>CodeReview</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><lastBuildDate>Sat, 10 Oct 2020 00:00:00 +0000</lastBuildDate><image><url>https://jacobaloysious.in/images/icon_hu4591c05f594249c11c1e99a3a8f1f246_3759739_512x512_fill_lanczos_center_2.png</url><title>CodeReview</title><link>https://jacobaloysious.in/tag/codereview/</link></image><item><title>Code Reviews</title><link>https://jacobaloysious.in/post/tech_code-reviews/</link><pubDate>Sat, 10 Oct 2020 00:00:00 +0000</pubDate><guid>https://jacobaloysious.in/post/tech_code-reviews/</guid><description>&lt;p>While working in a development team; being part of the code review is not an optional thing. Depending on the size of the org/team and the # of features in parallel - I am sure, we will get multiple code review requests in a week.&lt;/p>
&lt;p>I often ask myself, can I provide valuable feedbacks on every review I am part of? Most certainly NO! lets be honest here.&lt;/p>
&lt;p>Then the next question is - why are you added into the review? well I could think of two reasons:&lt;/p>
&lt;ul>
&lt;li>FYI: Let the team know I made this change; there could be depenencies (another developer; working on similar files)&lt;/li>
&lt;li>Status update (stakeholders)&lt;/li>
&lt;/ul>
&lt;h3 id="not-an-active-reviewer">Not an active reviewer:&lt;/h3>
&lt;p>If you think, you don&amp;rsquo;t have the right context to contribute. It&amp;rsquo;s good to be explict and call out - &lt;strong>Sorry, I don&amp;rsquo;t have enough context to add value. I would leave the review to the experts&lt;/strong> and recommend the author to mark you as &lt;strong>Observer&lt;/strong> instead.&lt;/p>
&lt;p>Note: code review is not a place to train; where you discuss and use it as a learning form.&lt;/p>
&lt;h3 id="add-value">Add Value:&lt;/h3>
&lt;p>This is critical and most important objective of a code review. Pointing out each and every spelling mistake and intendation fix - might not add much value; in which case - propose them to run it through a FxCop/style/code analyser utility.&lt;/p>
&lt;p>You absolutely need to be aware of the context before providing feedback 👀. If you are not sure about the specifics, setup a meeting and request the developer to walk you through. At the end of the day - &lt;strong>code is the ground truth&lt;/strong> (irrespective of what was aligned). Few example of real Value could be:&lt;/p>
&lt;ol>
&lt;li>Pointing out specific use cases not handled&lt;/li>
&lt;li>Usage of design principles (SOLID) - coupling/cohesion etc&lt;/li>
&lt;li>Adding: Validation, Logging, Tracablility etc&amp;hellip;&lt;/li>
&lt;li>Handling: Errors, Exception, Leaks, Performance etc..&lt;/li>
&lt;li>Code Coverage, appropriate tests (note: test should also be as clean/maintainable as SUT)&lt;/li>
&lt;/ol>
&lt;h3 id="assumptions">Assumptions:&lt;/h3>
&lt;p>This could at times come back back and bite; I have been there 😕. If you are not sure about a specfic change again: &lt;strong>call out explicitly and confirm - if your understanding is accurate&lt;/strong>.&lt;/p>
&lt;p>As authors - we do want our code to be non ambiguous. But, since there is always a context and depenency in the code - its hard to describe everything. Maybe better naming could help? well: 😏&lt;/p>
&lt;blockquote>
&lt;p>There are only two hard things in Computer Science: cache invalidation and naming things.&amp;ndash; Phil Karlton&lt;/p>
&lt;/blockquote>
&lt;h3 id="no-condescending-words">No Condescending words&lt;/h3>
&lt;p>Thanks to
&lt;a href="https://www.michaelagreiler.com/" target="_blank" rel="noopener">Doctor McKayla&lt;/a> for this.&lt;/p>
&lt;blockquote>
&lt;p>Words such as “just”, “easy”, “only”, or “obvious” can come across belittling and condescending. It’s a good practice to remove those words from your feedback. Most of the time, they do not add any value&amp;hellip;.. research shows that people have a tendency to interpret written language in a negative way.&lt;/p>
&lt;/blockquote>
&lt;p>Personally, I am cautious to ensure my review comments looks like a conversation - than a direct command.&lt;/p>
&lt;h3 id="more-the-number-of-reviewers">More the number of Reviewers:&lt;/h3>
&lt;p>I remember receiving emails like &amp;ldquo;please review my change set&amp;rdquo; sent to a DL which had 30+ developers.
Do you think all 30 members would have all the required context or would &lt;strong>you ensure&lt;/strong> all 30 will follow up and get the context and then do the reivew? Less likely! 🤔&lt;/p>
&lt;p>Maybe there is a perception that more the reviewers; more the # of valuable feedback. But, what if its the other way - every one assumes its someone else responsiblity - zero feedbacks 😟.&lt;/p>
&lt;h3 id="separate-feature-addtion-and-refactoring">Separate Feature Addtion and Refactoring:&lt;/h3>
&lt;p>Many at time its intriguing to refactor the code while we are working on a feature. We should - its always a good practise to &lt;em>clean up&lt;/em> and &lt;em>make it better&lt;/em>.&lt;/p>
&lt;p>My only argument here is: If you have both - the feature implemetation and refactoring in the same changeset (esp on a large code base, spanning files/dependencies) - It becomes a challenge to follow the &lt;strong>actual functional&lt;/strong> change.&lt;/p>
&lt;p>Recomendation: split them into two changeset like
&lt;a href="https://www.michaelagreiler.com/stacked-pull-requests/" target="_blank" rel="noopener">StackedPullRequest&lt;/a>: Personally would prefer (2) followed by (1)&lt;/p>
&lt;ol>
&lt;li>Only refactoring. No feature addtion&lt;/li>
&lt;li>Only feature addition&lt;/li>
&lt;/ol>
&lt;h3 id="unsure-of-the-reviewers">Unsure of the reviewers?&lt;/h3>
&lt;p>If you are already part of the team which maintains the code; no brainer. You are here since you are not sure - simplest tip &lt;strong>Go for history&lt;/strong>.
I have done this more than once; say making a change in deploy scripts maintained by operational team. Look for atleast 2 developers based on change history (again: don&amp;rsquo;t stop with one) of the file(s); secondly: make sure you look at their org structure and see if they belong to the operational team (If I get to deliver and someone else sends me a new review request 😑); finally: just to be sure add their solid line into it (why: well, you are unsure if you would get a response 😜).&lt;/p>
&lt;h3 id="approval-enforced">Approval Enforced:&lt;/h3>
&lt;p>Few companies have strict code review rules like: only a pull request that has 2 or more approvals - would be merged into mainline. I feel this culture/process is awesome; as there is definetly a sens of responsibility and ownership on the part of the reviewers - at the end of the day again (would say it multiple times) &lt;strong>&amp;ldquo;Code is the Ground Truth&amp;rdquo;&lt;/strong> (irrespective; what ever the feature/design document says).&lt;/p>
&lt;h2 id="conclusion">Conclusion:&lt;/h2>
&lt;p>I personally belive, Code review are not optional. Anyday - another pair of eyes would give you a different prespective. While, we as developers are more focused on getting thing done, there are chances of scenarios getting overlooked - effective code review enable us to bridge this gap. This defintely requires commitment and trust between authors and reviewers.&lt;/p>
&lt;p>Building a culture toward delivering quality code with code review as pivot is critical.&lt;/p>
&lt;p>Check out:
&lt;a href="https://www.michaelagreiler.com/" target="_blank" rel="noopener">Doctor McKayla&lt;/a>; there are lots of good content on this topics.&lt;/p></description></item></channel></rss>