⬆️ ⬇️

10 tips to review a code that you don’t like

I constantly commit to open source projects (Red Hat and others). And he noticed that the most negative time was taken by the code review, subjective in essence. Most often this happens with commits, where the maintainer for some reason does not like your change. At best, such a code review strategy leads to a loss of time in meaningless disputes; in the worst case, he actively impedes kommit, creating a hostile and elitist environment.



The revision code should be objective, concise and, if possible, contain only certain facts. This is not a political or emotional dispute, but a technical one. His goal is to move forward, develop the project and all participants. Any commit should be evaluated only on the merits, not on the subjective opinion.



Code Review Strategies



Here are some strategies to keep in mind when reviewing the code that you (as a maintainer) for some reason do not like:



1. Rephrase the objection in the form of a question.





2. Avoid exaggerations



Simply express your concerns and ask questions to help achieve the desired result.

')



3. Keep snide comments with you



Some thoughts are better to keep with you. If you can not say politely, better keep silent.





4. Act positively



Maybe you had a different idea on how to solve the problem? If you act positively, you will eventually find a solution that is better than any of the original options.





5. Remember that everyone has different experiences.



In all other respects, an absolutely competent engineer may not know certain facts for years that you take to be common sense. There is nothing wrong with saying the obvious thing, unless you are patronizing or maligning.





6. Do not diminish the complexity of what is not obvious.



Remember that things that are obvious to you may not be obvious to everyone. By offering alternative approaches and pointing out useful examples, you will help everyone synchronize.





7. Be respectful



Sometimes a commit just doesn’t meet the minimum quality standard. It is quite normal to say this, but to show respect does not require additional efforts.





8. Manage expectations (and your time)



If the commit is too large and cannot be considered quickly, then it’s ok to say so immediately. Then look for a solution.





9. Say "please" (be polite)



Just saying “please” you show that you respect the sender’s time, especially when you want to change the formatting or style, which may seem like a minor change. Examples:





10. Start a conversation



If after all this you still don’t like something, but you’re not sure why you might just have to accept it. Or to say: “I don’t like it, but I’m not sure why, can we talk about it?” This is a reasonable question, and even though it may take a little time, it is often worth it because you now have two people, and both learn (to explain and listen), not two people who confront each other.



Even qualified and experienced engineers should be able to say, “I don’t understand why I don’t like it.” This is not an invitation to attack the position of the reviewer, but rather an honest search for knowledge.



Summary



Avoid hyperbolic or pompous statements, avoid disputes, elitist or degrading expressions and constructions like "obvious" and "why would you just ...". Use clear, factual statements and supporting language, ask questions and move forward. Remember that colleagues and contributors are people too. Their time deserves the same respect as yours.

Source: https://habr.com/ru/post/459718/



All Articles