By Mark Christian and Duretti Hirpa
Last time, we talked about empathy and what goes into good pull requests. This time, let’s talk about the other side of the equation: what makes a good code review?
Why are we doing this?
First, it’s important to remember why we’re bothering with pull requests and code reviews in the first place.
- They offer us an opportunity to share and explain our work.
- They give us a place for feedback.
- They demonstrate that we are responsibly managing which code we ship to our users.
- They give us a chance to teach (by introducing people to a new part of the code) and learn (by receiving feedback).
Each of those reasons is different, but the same strategies are important for all of them.
Good code reviews are not rushed
Take your time. Relax. Drink some coffee.
Code reviews aren’t a distraction from your job: they are your job.You are here to help build an amazing product, and ensuring that we all do a good job is an important part of that.
Good code reviews are confident
If you’re new to the project, you will probably not feel comfortable reviewing code at first. That’s okay! You’ll probably feel confident saying “not okay” sooner than you will feel confident saying “yes, ship it!”, and that’s okay, too.
Make sure you know your own comfort zone. An approval without any confidence behind it isn’t really worth much.
Good code reviews are not superficial
People who are new to your project might need a helping hand in getting used to your project’s coding style, but in general, reviews shouldn’t be too focused on superficial issues like code formatting. Readability still matters, of course, but try to focus on the big picture. Consider whose code you’re reviewing and try to anticipate what they need.
Good code reviews require understanding
If you don’t understand the code being changed, go read the current version. If you still don’t understand, ask questions. Make sure you really understand. At the end of all that, if you feel totally out of your depth, that’s okay: pass the review on to someone who has more context, and follow-up on it later so you can learn.
Asking clarifying questions can help the author of the pull request understand better, too. Talking about the changes and bringing up edge cases are some of the most valuable things you can contribute to a code review.
It can be helpful to summarize your understanding in a comment — putting your thoughts into words will help you solidify that understanding, and it will also let your reviewer know that you’re paying attention.
Good code reviews share knowledge
Does this bug seem familiar? Is it touching some code you were in recently? Maybe you can do more than just review their branch.
Share your knowledge. Reference old bug reports. Solve the problem at a deeper layer. When you work with another person on something, you both get better.
Good code reviews are not huge
If you find yourself writing more than a sentence or two, or fundamentally disagreeing with a big part of the work that was done, or going back-and-forth with the other person, maybe code review isn’t the right place for the conversation. Go talk to them one-on-one so you can get onto the same page.
In general, rather than ambushing someone with a huge list of public comments, consider talking to them privately. This leads into our final topic…
Good code reviews have empathy
Finally, and most importantly, the awkward, fuzzy part: be empathetic. Remember, there are four components to empathy:
- to be able to see the world as others see it
- to be nonjudgmental
- to understand another person’s feelings
- to communicate your understanding of that person’s feelings back to them
If you see a problem with the code, try to put yourself in their shoes and try to help them see the problem without making them feel like a screw-up. Even experienced developers flub this part sometimes! It’s super hard. Sometimes, you will make mistakes. It’s okay — just work at it.
The way you write is everything. Don’t correct people — ask them for clarification. Assume they know something that you don’t. This is a really important thing! Assume that your co-workers are smart and are doing a good job.
Written communication can be tricky — it’s missing a lot of the social clues that let people know what you’re thinking. It’s easy to put people on the defensive, so take the time to try to use empathy words. — “us”, “our”, “we” are much better than “you”, “your”, and “mine”. You’re all on the same team, after all.
In conclusion
Pull requests & code reviews are where code meets people. It’s about communication more than it is about code, so take your time, do a good job, and think of the human being on the other side of the pull request. Good luck!
相关推荐
This article aims to provide a detailed walkthrough of Code Collaborator, focusing on its features, benefits, and how it addresses common challenges faced during peer code reviews. #### Introduction...
Code reviews: Enforcing a style convention using a checklist, the LabVIEW VI Analyzer Toolkit, and peer reviews Appendixes: Convenient glossary and style rules summary < LI>< UL> This book will be ...
You’ll learn about front-end build systems, popular Node web frameworks, and how to build a web application with Express from scratch. You’ll also learn how to create automated tests and deploy ...
It's supported with code examples that you can download and use to realize your own great ideas. This book's authors are responsible for some of the all-time most popular and talked-about games: *...
how to write code designed for others to use simple techniques that can lead to huge performance improvements advanced C++ techniques, including use of the STL (with lots of examples) And much much ...
and Olivier Hennessy and Clayton Kane (Apache Lander) have received glowing reviews and accolades for their games. Pair iPhone Games Projects with Apress's best-selling Beginning iPhone Development:...
Formal Reviews Coding Standards and Guidelines Generic Code Review Checklist Summary Quiz Chapter 7. Testing the Software with X-Ray Glasses Dynamic White-Box Testing Dynamic White-Box ...
Explains how to develop native code applications with Visual Studio 2010, develop database applications with SQL server compact, and use the application deployment option Discusses how to deploy a ...
5.0/5.0 1 reviews Details Title: Learn Swift by Building Applications: Explore Swift programming through iOS app development Author: Emil Atanasov Length: 366 pages Edition: 1 Language: English ...
“Android™ Database Best Practices goes well beyond API documentation to offer strategic advice about how to handle data in an Android application and the tools needed to develop productively....
The example reviews how to parse a text file, a technique that briefly appears in Chapter 1. The example also shows how to store information separately in both a list and a dictionary in order to ...
Editorial Reviews Product Description ASP.NET 3.5 is the latest version of Microsoft’s revolutionary ASP.NET technology. It is the principal standard for creating dynamic web pages on the Windows ...
Editorial Reviews Product Description ASP.NET 3.5 is the latest version of Microsoft’s revolutionary ASP.NET technology. It is the principal standard for creating dynamic web pages on the Windows ...
There is news, software, white papers, interviews, product reviews, Web links, code samples, a forum, and regular articles by many of the most prominent and respected PDF experts in the world....
He strongly believes that Flash Developers and Designers should be as comfortable with and passionate about code as they are about aesthetics and design. \"Flash allows you to bring everything ...
All bug reports, pull requests and code reviews are very much welcome. ## License Licensed under the [GNU General Public License, Version 3](LICENSE). ## F.A.Q 1. Why is my hashrate with Nvidia ...