DEV Community

Bhumi
Bhumi

Posted on

How to Have a Good Code Review Mindset, Tips for New Developers

Lot has been written about code reviews - how to submit good code reviews, how to be an effective reviewer, things to do and not do. What I want to talk about is the developer mind and the games it plays during this process.

Developers have feelings. Really. We feel good when we write code that works in production and is being used by real users. We feel bad when someone finds a bug in our code. We feel embarrassed when we submit a 20 line code review and there are 10 comments on it.

But actually this can be good news. It means we can now learn 10 things and our next code can benefit from those tips!

So how can we tell our mind to feel energized instead. Here are some things to try:

  1. Submit code reviews to one or two experienced developers who are also good at the art of reviewing code (i.e. don't submit to a dozen people). Find a willing developer and do a pre-review with them if necessary.

  2. Address all review comments as fast as possible and get back to the reviewer to tell them you've done that immediately. This helps keep up the momentum towards 'ship it!' which is important for your mind to not get distracted and feel lazy about following through.

  3. Ask questions to clarify the suggestion, use code snippets to ask specific detailed questions (would this line of code be better than this?). Don't engage in vague theoretical conversations.

  4. Once you've resolved all code review comments and made code changes, rerun tests and do basic sanity testing of the functionality before pushing (to confirm your new changes has not introduced bugs. You mind will feel good if you catch it and embarrassed if someone else does later)

  5. After you push code, keep an eye on the CI builds and if something breaks immediately jump in and investigate why (even if it is not your change, offer to help!)

  6. Keep a written list of all the tips you've gotten during code reviews and each time you're ready to submit a code review go through that checklist. So review your own code first, and try not make repeat mistakes (instead make new mistakes!)

Participating in code reviews like this demonstrates confidence. You're new and you're learning but you're confident and you know how to incorporate feedback. Nothing can stop you now! :)

In my first coding job after getting a computer science undergrad degree there was no real code review culture. It was a really big company and it was hard to figure out how to learn from other developers around me. I wish someone had told me to write code and get other developers to tell me what's wrong with it! And keep doing that until I could tell myself :)

Top comments (0)