Skip to main content

Great Code Reviews

As I've mentioned elsewhere, I've just started a new role at Anaconda.

A week after joining I was asked to contribute an article to an internal newsletter called "Consider This!". The format is simple: write something thoughtful on a subject of interest to folks within the company, and, at the end, curate a list of questions to prompt further thought and reflection.

I was invited to explore what I considered important aspects of great code reviews. Thanks to Anaconda, the article is reproduced below. Additional thanks to my colleagues Elise and Dan who provided invaluable and stimulating feedback to significantly improve my first draft.


Ask a room of engineers what makes a great code review, and you’ll have as many different opinions as there are engineers. Yet, in my experience, common themes and archetypes emerge from the gloriously colourful and diverse descriptions of a great code review. This article aims to explore what they might be.

At its core, a code review is exactly what it says: asking another to review code.

Why might one do this? Often the simple answer is, “because I have to”.

Code hosting sites, like GitHub, make it easy for code reviews to be part of the development process through concepts like pull requests (PRs for short). Simply make a change to the code, bundle your changes into a PR, submit it and wait for feedback from maintainers or colleagues. Sometimes you have to submit code for review because of corporate governance, your employer or the open source project to which you’re contributing may have an existing review process for all contributions. Or it may simply be habit or herd instinct to follow so-called “best practices”... folks do code reviews because everyone else does code reviews and so they’re living up to expectations.

A code review could be an assessment to overcome, where someone in authority accepts or rejects your changes. It might involve checking your changes to ensure you’ve followed stylistic and technical conventions for a project, like a teacher correcting work with a red pen. Furthermore, opinions about the approach taken, methodology used or even the intention behind the change might be offered, like a critic describing a restaurant, film or concert.

But there’s another, more engaging reason to participate in code reviews: if done well, your world as a coder is enlarged by the process, be that as a reviewer or contributor. In so doing, engagement with the project is a process of growth, and the quality of the codebase is improved to reflect the shared goals, ideas and aesthetic of those bringing the project into the world.

If a code review is used as a means of exercising authority then it’s no better than pandering to another’s ego. Many projects have stylistic and technical conventions, and checking such things can be easily automated so contributors are confident their changes meet such minimum requirements before ever submitting their code for review. Finally, if a critique of the approach, methodology or intent is offered as part of a code review, then it’s happening too late; such things should be discussed before code is submitted for inclusion in the project, perhaps in early drafts (so called “code spikes”) or exploratory proofs-of-concept.

From the contributor’s point of view, a code review is an opportunity to share their work so others understand and see what they are offering. In other words, a code review is an exercise in education as others encounter and explore new aspects of the code base. From a reviewer’s point of view, a code review is an opportunity to explore, internalise and offer constructive feedback of another’s contribution. Once again, it’s an exercise in education as the contributor is invited to explore their own work through the fresh eyes and constructive commentary of the reviewer.

Earlier, I deliberately used the word “enlarge” when I said a code review enlarges the world of those who participate. Enlargement is not synonymous with “fun”, “positive” or “easy”. The process of enlarging one’s view of the code might feel uncomfortable (perhaps you’re trying to get your head around a difficult or unfamiliar concept), negative (you feel frustrated with yet another bug in a hard-to-fathom part of the project) or difficult (the task at hand is complex and requires much effort simply to engage effectively).

Yet, enlargement implies growth, understanding and progress, and I’m reminded of the types of fun mountaineers use to categorise climbs.

A climb that is type one fun is fun because it’s fun to do, type two fun is not fun at the time but fun to recollect afterwards because of the achievement gained or lesson learned, and type three fun is not fun at the time, nor fun to recollect because you realise you never want to be in that situation ever again. Given a receptive spirit of learning, a mountaineer’s view of the world is enlarged through a mixture of both positive and affirmative, as well as negative and difficult, experiences.

So, how do we foster a spirit of enlargement in code reviews?

I believe mutual respect is key. Respect involves showing empathy, gratitude and acknowledgement that, when difficulties arise, folks involved are acting with the best of intentions. Another key factor is trust, an attribute of a team that only comes through working together over time, making mistakes together, and seeing evidence that folks support each other. I’d add that compassion (an awareness of and sympathy for another’s feelings and situation, mixed with a proactive desire to engage) is a great way to show support. When things inevitably become difficult, then compassion for each other is a way to embody mutual respect and build trust.

In the context of code reviews, such attributes help our judgement to become deeper, more refined and aware of the wider context of the project and its participants. A code review is no longer just an arbitrary measurement of “quality” (have you followed our code conventions?), but becomes an exercise in mutual learning and improvement that encompasses both enjoyable and challenging aspects of participating in a coding project. At the heart of this process is a strangely humorous paradox, as demonstrated by this old joke:

STUDENT: O Guru, what is the secret of success?
GURU: Good judgement.
STUDENT: How do you get good judgement?
GURU: Experience.
STUDENT: How do you get experience?
GURU: Bad judgement!

Only when folks feel safe to exercise potentially bad judgement (through the code they offer or the feedback they give), will they be able to gain experience and learn good judgement. The code review is a place to pay attention to each other’s contributions to facilitate mutual learning and growth. This will, ultimately, improve the project as a whole, and help its participants better engage with the tasks at hand.

“But”, I hear you ask, “what things should one do in a code review?”

If you’re expecting a “top ten interventions to make in a code review” type post, you’re in the wrong place. In fact, such naive shopping lists demonstrate a rather transactional and limited view of the process of a code review, while completely missing the point I’m trying to make. I hope you focus on embodying and passing on the sort of attributes that make a project an enlarging place in which to contribute: mutual respect, trust and compassion.

Perhaps we could learn by examining what other disciplines do when something is offered and feedback is given. For example, such a process is at the heart of musicians rehearsing (no matter the genre of music).

This short fragment shows Leonard Bernstein rehearsing an orchestra. Clearly the triangle players are not playing to the high standard he expects.

I want to draw your attention to the relationship between the musicians involved. How do Bernstein and the percussionists appear to you?

Folks might think Bernstein is condescending, sarcastic and not particularly supportive. Others might see him as setting clear (and very high) expectations through humour. Others might focus on Bernstein’s clear ignorance of triangle playing and the resulting laughter from the percussionists. That we see the same thing in different ways is itself an interesting and important outcome of our diverse and multifaceted backgrounds (and it’s important to acknowledge and recognise such differences).

The important relationship, upon which I want us to focus, is that between Bernstein and the musicians. Only when there's mutual respect, a feeling of safety and trust can such potentially difficult conversations, involving the giving and receiving of constructive criticism to fulfil some important end, take place. How such discussions unfold will reflect the unique relationship cultivated between the participants. So long as both parties share a bond of trust and respect, and we recognise and respect such a bond reflects their unique relationship with each other, then we can engage with and learn from the feedback and what the outcome tells us about the endeavour. In other words, our world is enlarged by observing their interactions.

Questions to Explore:

  • How has your world been enlarged through a recent code review?
  • Remember a time when you received valuable feedback or an important lesson that enlarged your world; how was it revealed to you?
  • What is your team’s approach to code reviews?
  • How do you and your collaborators cultivate a place of mutual respect, trust, and compassion?
  • Put yourself in Bernstein’s shoes, what would you say to the percussionists?
  • Imagine you’re the percussionists, how would you respond to Bernstein’s feedback?
  • Think of a recent PR submitted for you to review. How did you help enlarge the world of the author? How was your world enlarged?

EuroPython 2022

I had a wonderful time at EuroPython, last week, in Dublin.

The most important aspect of the conference, for me personally, involved giving my talk entitled "Music and Code". It was an opportunity for me to reveal and explore how I feel about programming, teaching and learning and the place of tech in our wider culture. I've wanted to give a talk like this for over ten years, but only recently have I figured out how to express what I wanted to say through music as a metaphor.

Another important aspect of the conference was friendship and it was a huge pleasure to be a small part of the organising team.

I especially want to highlight collaborating with Vicky (a remarkable friend who embodies so many of the wonderful aspects of our Python community: a pro-active "can do" attitude, an inclusive and compassionate outlook towards others, and a formidable determination to thoughtfully do "the right thing" for the benefit of the whole community). The two of us flapped and faffed to fulfil a Maker space within EuroPython. Given the amount of positive engagement from attendees, I hope this becomes a regular feature of the conference. A case in point being the DIY robots competing to solve a maze in the fastest time, organised by the energetic and enthusiastic folks at the Northern Ireland Jam:

I also want to mention Raquel, who chaired this year's EuroPython. Her clear leadership, from the front, her apparently infinite energy, displayed through her considerable efforts, and her humane connection with folks, embodied by her patience, friendliness and compassion are generous gifts she has shared with us all. I sincerely hope she's taking some post-conference time off, and I want to thank her for reaching out to me, all those months ago, to become a part of organising EuroPython. And I have to say all my fellow organisers were an absolute joy to work with. Their collective courtesy, hard work, enthusiasm and friendliness is a very rare and special thing that I hope we can sustain, nourish and cultivate.

One other group of friends deserves a mention - my fellow maintainers of the Mu code editor. It was a huge amount of fun for us to be together in the same place for the first time ever. I was especially delighted to meet Vasco, face to face, for the first time.

The final part of EuroPython were two days of "code sprints", where open-source collaborators work together on their projects, meet to discuss technical and other aspects of our collective work, and welcome new collaborators and friends to our efforts. We, the maintainers of Mu, had a wonderful time focusing on Mu related things, and collaborating with new contributors who have made welcome enhancements to Mu.

Here's a picture of all the Mu maintainers at EuroPython:

The five core Mu maintainers
The five core Mu maintainers: Tim, Tiago, Carlos, myself and Vasco.

Of course, I heard many wonderful talks, enjoyed the conversations with many friends old and new in the famous corridor track and took part in some really stimulating workshops (with my amazing daughter, who was attending her first PyCon as a proper attendee with an interest in data science - she especially enjoyed both Django Girls and Humble Data).

I love EuroPython's culturally cosmopolitan feeling, something that's hard to recreate at a national PyCon. I love how folks keep coming back to EuroPython, there are people who mean a lot to me, who I only ever see at this conference. I also love EuroPython's peripatetic nature, as a community we are welcomed to all sorts of fun places and have an opportunity to soak up the vibe of different countries and cultures.

Long may it last, and I hope to see you at next year's EuroPython.

Pastures New

I have been a freelance software engineer for almost 17 years. In that time, as is usual for a freelancer, I have changed roles every 18 months to two years. Often I took time off between gigs to work on personal projects, write, reflect or learn something new. For instance, in 2008 I left my role as a senior .NET developer for an investment bank in London to learn Python, then reset my career as a junior Python coder three months later and never looked back.

I've relished my freedom and independence, and it has been a privilege to work on a huge variety of projects for a diverse range of companies in many different sectors. I have been enriched by my colleagues, made many wonderful friends, and learned a huge amount from folks.

Thank you everyone.

Yet change is in the air... Since January I've been in discussions with Anaconda and from today (the Northern Hemisphere's summer solstice no less!), I'm delighted to reveal I'll be joining them as a principal engineer. Long may the sun shine on this endeavour. 🌞

The very big change for me and my family is that I'm an employee rather than freelancer.

A big factor in persuading me to step away from freelancing were the folks I met in interviews and the company culture I encountered leading up to my offer of employment.

Another important factor was the nature of the work I'll be doing. I can't go into details, but I'm very excited to work with an exceptionally talented group of folks, on something that I'll relish getting my teeth into. Importantly, it is an opportunity for me to bring together and use skills from many different aspects of my background.

Finally, Anaconda understand what motivates folks passionate about creative coding: I'll still be active as an open source contributor and will continue to develop projects such as CodeGrades in my own time, as has been the case so far.

Here's to new adventures.

Offa's Dyke - Days 10, 11 and 12:

We found our relaxing rhythm during the final few days of our holiday. Our lack of a plan allowed us to follow our noses, and intuitively improvise an itinerary during each day. As you'll see from the photos below, we spent a lot of time focusing on four things: historic monuments, gardens, food and travel through beautiful places.

Our tenth day started with breakfast in Ruthin, at Gail's coffee and tea rooms on Upper Clwyd Street. Many of our stop overs have provided us with spectacular food and drink, and the vegetarian full cooked breakfast at this modest and out of the way cafe was up there with the best. Their friendly chef suggested a few sights to see in Ruthin and furnished us with a map. And so our typical modus operandi of chatting with locals and improvising on the spur of the moment led us to the grounds of Ruthin castle.

Peacocks in the gardens of Ruthin Castle.
Peacocks in the gardens of Ruthin Castle.

The chef at Gail's had explained the peacocks who live in the castle grounds were a friendly bunch, and we were not disappointed to find several of them displaying to the peahens.

Ruthin Castle gardens.
Ruthin Castle gardens.

The castle itself was undergoing renovation, since the original fortified remains had been converted into a stately pile during the 19th century, and were now used as a hotel of some sort. With the abundance of dramatic castles in this part of the world, it was inevitable we'd find a few that had been repurposed.

Our chef at Gail's also suggested we visit the Ruthin Arts Centre, and we spent an extended period of time wandering the relatively small but open plan galleries. Both Mary and I particularly enjoyed the exhibition of husband-and-wife artists Pauline Burbridge and Charlie Poulsen. We immersed ourselves in the artworks and lost track of time... as we encountered the art in three distinct phases:

  • slow wandering around the exhibition as we let our intuition guide us as we were drawn different pieces,
  • a sort of inquisitive "deep dive" as we read the prose attached to the exhibitions and watched a couple of videos where the artists describe their works, process and intents,
  • a recapitulation as we explore the exhibition one final time now that we're more familiar with the pieces, the artists and the story being told.
A fragment from a Charlie Poulsen piece.
A fragment from a Charlie Poulsen piece.

This was a wonderful state of mind to inhabit and we both wished there had been more of this to explore and encounter.

Having put us both in a thoughtful mood, and given the glorious weather, Mary suggested we go visit Bodnant garden to continue our pensive strolling. Since we had the car and we felt like touring through North Wales, we instructed the sat-nav and slowly wound our way to our destination.

We were not disappointed.

Bodnant gardens.
Bodnant gardens.

We found ourselves in a large and varied garden containing an abundance of benches on which we could both sit, look, listen and soak up our surroundings. I think my favourite aspect of the gardens were the woods containing paths and shallow brooks and many different sorts of tree and woodland life.

As with the art gallery, our slow meandering meant we encountered and re-encountered aspects of the garden in a manner that encouraged a slow and thoughtful attention to all the ways the garden stimulated our senses: the colourful floral displays, smell of pine, sound of running water or warmth of the sun touching our faces.

Bodnant gardens terraces.
Bodnant gardens terraces.

In the evening we found ourselves staying at a community run inn that was holding a quiz night. After an early dinner we joined the locals and had a friendly evening answering questions about such diverse topics as the game of Cluedo, Elton John's back catalogue, the plural noun for crows (it's a "murder" of crows, in case you're wondering), and other out of the way trivia. The quiz was both taken seriously, yet in a spirit of silliness, as many of the locals made humorous commentary of the emerging themes in the questions.

Once again, our modus operandi of chatting with locals and improvising on the spur of the moment led us to something fun.

Our penultimate day started with the realisation that it was our penultimate day. So, we decided to make use of the car and go visit the seaside, since that was the only type of terrain we'd not yet visited during our break. We chose to head towards Porthmadoc since it would mean driving through the beautiful Welsh mountain range called Snowdonia.

The journey was, indeed a sight to behold as we made our way to the coast, yet upon our arrival at Porthmadoc we both felt underwhelmed by the place. Wondering what our options might be, and in the spirit of improvisation, we spotted a castle on the coastline in the distance and pointed the car in that general direction only to pick up signs for Harlech Castle.

Harlech castle.
Harlech castle.

This well preserved ruin is an imposing sight so we imagined it would be very busy with tourists, due to its prominence. Yet the village was relatively empty and we easily got into the castle.

Not only was the castle an amazing sight, but the views from it were magnificent as we were able to take in a full panorama from the Irish sea to the mountains of Snowdonia.

The view of Snowdonia from Harlech.
The view of Snowdonia from Harlech.

Because of its good state of repair, it was possible to explore many different parts of the castle. For instance, we walked up and down spiral staircases to get to the battlements and then to the very highest tower. I'm OK with heights but Mary (and several others) found the drop from the walls rather intimidating and so we didn't spend that long up there. Luckily it was a bright sunny day with little wind to speak of, otherwise I imagine the reaction of folks might be very different.

Walking the castle walls of Harlech.
Walking the castle walls of Harlech.

As we were having our lunch we noticed a cameraman and several people faffing about and talking about "positioning", "shots" and "delivery". One of them, a lady in sunglasses, spotted us watching the events unfold and came over to explain what was going on.

It turned out she and her colleague were professional story tellers specialising in Welsh legends (particularly, the Mabinogion), and were at Harlech to tell stories in both English and beginner level Welsh, to help keep this beautifully musical language alive. The UK's ITV news had turned up to do a short feature on their work and were just filming a talking head segment in front of the castle before filming the actual story telling in the castle.

We didn't realise such bardic activity was going on, but both of us love listening to a well told yarn, so quickly finished our lunch and headed back over the bridge into the castle.

Inside we found perhaps a hundred people sitting on benches, low walls and the grass as our bespectacled friend started to tell us a story. I won't describe stories she and her colleague told. Rather, I heartily encourage you to seek out such folk and let them cast their magic. In our case, as they told their tales in Harlech, the story tellers embodied and communicated the worlds they described in a way that only an oral story teller can. The best special effects happen as part of the story seen inside one's head, the interaction between the story teller and their audience adds an extra dimension of connectivity to the telling of tales that our screen laden world often lacks and, ultimately, our stories are just that... connections between ourselves that deeply and fundamentally move and speak to us through distances of time and space.

Here's the video segment broadcast by ITV, it is but a shadow cast by the brilliance of their story telling:

We must have spent hours in the castle, since we both mentioned exploring the village of Harlech at the same time. Almost immediately we discovered a small ice cream shop, selling home made produce made earlier in the day. This was some of the best ice cream either of us have ever tasted, and the owner explained how she hand made the produce fresh each day. Clearly this woman had a passion for ice cream, and we could taste it in abundance.

Mary, with her amazing ice cream.
Mary, with her amazing ice cream.

Just around the corner was an knick-knack shop in which I found a piano. On the music stand was Debussy's Clair de Lune (which I know), so I rattled it off, after finding a very convenient candelabra to help free up a hand.

Nicholas on the piano, but where is his ice cream?
Nicholas on the piano, but where is his ice cream?

It was lovely to play after more than a week away, and I even got a round of applause!

Upon leaving Harlech we decided to take the long and winding road over the mountains of Snowdonia, just to take in the views and make space for enjoying a slow and gently winding journey together.

Snowdonia.
Snowdonia.

On the morning of our final day (today), we finished the last of many full breakfasts and set off for Prestatyn to conclude our walk.

The sign to Chepstow.
The sign to Chepstow.

Little did we realise, almost a fortnight ago, how different our adventure along Offa's Dyke would be, compared to what we had imagined or prepared for. We certainly enjoyed walking the first third of the trail (almost 60 miles), and we both reflected that the injuries and improvised change to a touring holiday had taught us a lesson: go with the flow, and unexpected change is to be embraced and welcomed if you're going to make something of it.

The stone marking the end of Offa's Dyke.
The stone marking the end of Offa's Dyke.

In the end, as I write this back at home in Towcester, both Mary and I feel glad to have returned after our journey together. We're especially looking forward to seeing our children again and giving them gifts we found on our way.

But I think this won't be the last time Mary and I do this.

We've had too much fun not to do it again.

The two of us, at the end of our adventure.
The two of us, at the end of our adventure.

Onwards!