Nonviolent Communication in Code Review: Receiving Comments
Tags: eq, communication, empathy
Published: 2019-10-21 23:11:15

---
title: Nonviolent Communication in Code Review: Receiving Comments
published: true
description: Parsing Emotions, Thoughts, and Needs in Comments
tags: EQ, communication, empathy
---

This post is about communicating with humans, and sorting through the complexities of our day-to-day lives, such that we start to think about the ways to communicate with others to enrich those experiences.

I decided to write this post because I was reading a different blog post about code review, and what things we should and should not say. The post listed a few examples of comments that could raise negative feelings in the author; comments like "Why did you do it this way?", or "THIS IS TERRIBLE! REWRITE IT!" The one that made me stop was:

"I don't like this."

At first glance, it seems relatively harmless, but it is difficult to communicate tone properly on through text. Not everyone can write down their thoughts and feelings like a Hemingway or Shakespeare, and we all interpret comments in our own way; the impact the reader gains can be completely different than was the writer's intent. Let's spend some time analyzing this comment, and show how it and other comments like it can open into to a rich and fulfilling experience between author and commenter.

We will first examine the four components of nonviolent communication, outlined in the book [Nonviolent Communication, by Marshall P. Rosenberg, PhD](https://www.amazon.com/Nonviolent-Communication-Language-Life-Changing-Relationships/dp/189200528X). We will then walk through a scenario starting with this comment in which the author responds in a nonviolent way.

**Before diving in, take a moment to imagine or remember a similar situation and consider how you might personally respond to this comment. What did you say to this hypothetical person? Keep it in mind.**

## What is Nonviolent Communication?
It is a style of communication devised by Dr. Marshall P. Rosenberg that focuses on the emotions, thoughts, and needs of speaker and listener. We often don't like speaking on our emotions in a work setting, but that's merely a product of our society; one that we need to overcome. We are all humans, we all have emotions, and we all have needs. Being able to communicate those in an open, vulnerable way is at the core of creating real connections, and being able to communicate with one another on the most human level.

There are four main components to nonviolent communication:
1. *Observing events without judgement.* This is looking at a situation and seeing what happened literally. This can be difficult, and subtle. One example would be the difference between "Your PR is HUGE!!", versus "Your PR is 1,126 lines!" ("HUGE" is a judgement here).
2. *Recognizing the emotions that the events incite within us, as well as the thoughts that surround those emotions.* Recognizing emotions - stepping back from a situation and understandind what we are _feeling_ - takes practice, and we might not have a word to pin on our feelings. Also, it is important to distinguish here the difference between what we are _thinking_ and what we are _feeling_. We feel emotions, such as happiness, sadness, anger. We _think_ a PR is huge. Here's an example: "I feel like your PR could be smaller" talks about feelings, but contains none. "I feel weary from reading your PR, and I think there is work that can be done to break it into smaller, more digestible pieces" mentions the feeling, _and_ the thought around it.
3. *Understanding the needs that the emotions stem from.* We all have needs that we want fulfilled, and our needs are different from those of others. Perhaps the need that might lead to weariness in reviewing a long PR might be the need for simplicity, or brevity, so that we can ensure that the code is well reviewed, and we can feel assured that it will not cause production incidents.
4. *Making a request that will enrich life.* After we have identified our feelings and needs, it is now time to make a request of the individual(s) we are communicating with: "Could you break this into smaller PRs that can be individually reviewed?" It is important that our request is one that does not act as a demand in disguise, but relies on the individual(s) to which the request is directed to receive it compassionately, with understanding and empathy, and to fulfill whatever it is we are wanting them to do.

## Responding to Terse Comments

Now that we have a basic understanding of nonviolent communication, let's try and understand how we can apply it to our code review, and see the benefits it could have in our thinking.

Focusing back on the comment "I don't like this.", there are four options we can do when we read it. **Try to match one of these options to your response from earlier**:
 -  **Blame yourself.** "Yeah, this is bad, maybe I could do it better."
 - **Blame the commenter.** "This is an unhelpful comment."
 - **Understand what it is you are feeling and needing.** "I am confused by this comment, and I need clarity as to what this person means."
 - **Try to understand what the commenter is feeling and needing.** "I see that this part of the code makes you unhappy, what is it that you do not like about it? Could you explain further?"

The first option is full self deprecation and shame. I could go deeper into how our society has trained us to feel shame and how we often speak to ourselves negatively ("I'm so dumb, why did I do that?") instead of being empathetic towards ourselves, but that is a long talk in itself.

The second option ignores the comment, and retaliates. Responses of this nature mean shutting down and not receiving the message compassionately, placing blame on the commenter. This will likely lead to more negativity.

The third option involves empathy towards the self. Instead of responding with a kneejerk reaction, it is important to take a step back and understand what it is we are feeling when we read a comment like this. In my experience, I often find comments like this frustrating because they do not fulfill my need for clarity, or actionability. I would respond to this comment with a request to explain further what it is they don't like, or what I could do to fix it.

The fourth option is empathetic towards the commenter. Perhaps they are having a bad day, perhaps they just got out of a long meeting and are mentally exhausted. You can only guess, and understanding that you do not know where they are coming from when they make such comments is the first step to empathy. We can show compassion towards the commenter, and try to understand their feelings and needs.

## A Scenario

Again we look at the comment, "I don't like this." The comment has no written context, and may only be attached to a certain line in our code. Maybe it is localized enough that we can see what they are saying immediately, but maybe not. Let's look at a possible scenario that starts with this comment and opens up into something wonderful:

  **Author:** *codes*

  **Commenter:** I don't like this.

  **Author:** I see that this part of the code makes you unhappy, but I'm having difficulty understanding what is causing these feelings. Could you explain further, for my sake?

  **Commenter:** Apart from the fact that this PR is over a thousand lines long (yikes), I've seen this method used before and often it has unintended consequences because it's got a lot of unintuitive return values. I don't know if it's being used correctly, and I can't quite see how it will affect the code downstream.

  **Author:** Thank you for this. I see that you are worried about the size of the PR, and that you may not be able to find issues in the logic that could cause bugs in production. Let me tell you that I am also wary of possible bugs; perhaps it would help to ease our fears if we pair on Monday and work through the parts that we think need the most attention? I have more context to share around this that I think will clarify why I wrote it this way.

**Commenter:** Sounds good. Thanks for understanding.

Notice that in their first response, the author takes none of what the commenter says personally. They made no judgements about the comment, communicated their difficulty, and requested further explanation for clarity.

From there, the commenter opened up. They gave much of what they are thinking. From here we can more easily guess at what they are feeling and needing.

The author reflects back to the commenter what they said to show that their comment was read. They address the feelings they found in the comment and echoed them. They then offer to spend time with the commenter, to resolve the issues present in the current state of the code.

The author could have _much_ more easily just responded to the first comment with, "This is a junk comment", which, as you might imagine, would stir up more negative feelings in the commenter. This could cause the commenter to shut down and not respond at all, skipping over the more detailed review, leading to buggy code shipped to production, and pager alerts at 3 AM Saturday morning. Yikes. Instead, the author took the time to look into themselves and find that the comment was causing confusion, and the conversation opened up by calmly requesting clarity. It is important to note here that you cannot effectively address someone else's needs without first addressing your own.

## Conclusion
How did you respond to the comment at first? We have seen now what nonviolent communication is. We have seen one small application of where it can be applied in our daily lives, and how it can lead to better outcomes.

Nonviolent communication is built on empathy, which is something not all of us are accustomed to practicing. It takes time, and energy, failure, and iteration, but using it leads to the creation of a deeper understanding of the people around you, their feelings and needs, and enables is to more easily create stronger connections with them, at a more human level.

Indeed, this post could have centered around _writing_ PR comments in a nonviolent way, and you can imagine there are many more applications we can apply this style of communicating both at work and in our personal lives. If you can think of a time where this method may have helped you, or if you have any questions or are in need of clarification (or have any other needs I might be able to address), please leave something in the comments!

Thank you for reading!