Introduction
Code reviews can be critical for ensuring code quality.
By scrutinising each other's code, we keep each other accountable.
We can:
π Enhance code readability
π Uncover potential bugs
π Share our knowledge
Ironically, the code might not be the most important aspect of a code review.
In this article, we explore the role of mindset during code reviews from the reviewer's perspective.
Key Takeaways π
β
Mindset Matters:
Your mindset directly impacts team dynamics, morale, and the effectiveness of feedback.
The right mindset promotes respect, trust, and collaboration.
Your feedback impacts your teamβs confidence and wellbeing.
β
Effective Code Review Practices:
Prioritise feedback on code quality, readability, and maintainability.
Offer specific suggestions rather than vague criticisms.
Show empathy for the author and sensitivity to time constraints.
β
Continuous Improvement:
You set the tone for a culture of continuous learning.
Use code reviews for knowledge sharing and skill development.
Encourage a growth mindset among your team to make the most of feedback.
Why Review Code?
Some teams insist on code reviewsβ¦ others donβtβ¦
Some benefits of code reviews include:
β Knowledge Sharing
β Code Maintainability
β Improved Code Quality
β Continuous Improvement
β Risk Mitigation (to some extentβ¦)
The Reviewer
Reviewers play a crucial role in the code review process.
The reviewer assesses the code submitted by their peers and ensures it meets quality standards.
As such, they need to have sound technical knowledge.
They provide feedback and guidance on the code they review.
π How they approach this depends massively on their mindsetβ¦
Reviewer - Fixed Mindset:
π΄ Believes that their way of coding is the only correct way.
π΄ Views code reviews as an opportunity to make themselves feel good.
π΄ Is resistant to receiving feedback on their suggestions and becomes defensive.
π΄ Judges the author's code based on personal preferences rather than objective criteria.
π΄ Focuses on finding faults rather than identifying areas for growth.
Reviewer - Growth Mindset:
π’ Has an open mind, and views code reviews as opportunities to learn and grow.
π’ Values constructive feedback and actively seeks to improve their own approach.
π’ Recognises multiple valid approaches to problem-solving and is receptive to new ideas.
π’ Focuses on providing helpful suggestions to support the author's development.
π’ Understands mistakes are part of learning and encourages experimentation and exploration.
Why It Matters π€·ββοΈ
Your mindset directly impacts the outcome of your code reviews...
π’ It impacts how well your message is received.
π’ It impacts the level of respect your team has for you.
π’ It impacts the morale and confidence level of your team.
π’ It impacts the wellbeing and mental health of your team.
π’ It impacts how willing your team will be to implement your feedback.
You need to recognise the potential for your team to feel judged and the impact you could have on their confidence.
You also have an opportunity to enhance growth, build trust and improve collaboration in your team.
Approaching code reviews with the right mindset helps build a positive team culture and creates a safe space for people to share their work.
Take Action π₯
Code reviews arenβt about marking someoneβs work as right or wrong.
Your actions can help someone grow or can destroy their confidence.
Code reviews are about teamwork and getting to the preferred solution for your team and business.
The next time youβre reviewing code, consider these Dos and Donβts:
Don'ts:
π΄ Block based on nitpicking:
Avoid blocking code reviews based on trivial issues that don't significantly impact code quality or functionality.
If you nitpick, call it out and flag it as a low priority.
π΄ Use vague or ambiguous feedback:
The last thing you want is for the code author to read your comments and not know what to do next.
Ensure clear, specific, and actionable comments to help understanding and implementation.
Consider jumping on a call if there are too many comments or the subject is complex.
π΄ Criticise without providing suggestions:
Avoid pointing out flaws without offering constructive solutions or alternatives.
π΄ Ignore context or project constraints:
Consider timelines and constraints when providing feedback to ensure practical recommendations.
Suggesting a complete rewrite of a feature is not helpful when the release deadline is a few hours away.
π΄ Be Rude:
Be mindful of how your comments might be received, and maintain professionalism and respectfulness in all communications.
Itβs not ok to be rude just because you feel frustrated.
Dos:
π’ Focus on the code:
Phrase comments constructively, focusing on the code rather than the person.
βDonβt do this!β - Isnβt helpfulβ¦
π’ Focus on high-impact issues:
Prioritise critical aspects such as security vulnerabilities, performance bottlenecks, and architectural concerns.
π’ Offer suggestions:
βThis is the wrong approach.β, isnβt super useful.
Explain why and provide a suitable alternative, a link to an article, or an example of where the correct approach has been used.
At the very least, ask probing questions to help the code author solve their own issue.
π’ Show empathy:
Be courteous and polite; the developer receiving your comments is a person and has feelings.
You donβt get the best out of them be belittling them.
Put yourself in their shoes.
π’ Be sensitive to time:
If a code review is time-sensitive, consider jumping on a call to rattle through it.
Richβs Recommendations
Check out my recommendations to improve your wellbeing, mindset, leadership or tech skills:
π Basma Taha - Your Guide to Fast-Track Your Software Engineering Career.
Newsletter: An Engineer's Echo
π
- Writes about career growth, study abroad and life experiences.He's a Tech Lead at Meta.
Newsletter: The Hustling Engineer
π Crushing Digital - Dave Roberts
Get help to stand out in the market, land more interviews and get the job you deserve.
π NKβs weekly newsletter to learn system design:
Newsletter: System Design Newsletter
π Dev Leaderβs weekly newsletter to help you level up as a software engineer!
From a Principal Engineering Manager at Microsoft.
Newsletter: Dev Leader Weekly
π John Crickettβs weekly coding challenge to help software engineers level up:
Newsletter: Coding Challenges
Closing
Hopefully, you recognise the critical role of mindset in code reviews.
I hope itβs enough to get you to think about your own approach.
Code reviews are a great opportunity, unfortunately missed by many.
By embracing a growth mindset, teams can create an environment where everyone feels valued, respected, and empowered to contribute their best work.
In my next issue, Iβll take a similar approach to this but focus on the code author rather than the reviewer.
Remember
There's nothing more important than your own wellbeing!
Code reviews are good for raising junior and mid-devs to senior level and an excellent opportunity for breaking the knowledge silos.
Great read!
Code reviews play a crucial role in making maintainable software, but if not done right, can have opposite effect.
I like the Don'ts you have in their, particularly on nits.
I believe code reviews should be standardized across an organization to avoid too much individuality and forcing own opinions onto others.