Alessandro Romano

The Empathic Tech Lead


Mindfulness for Developers: Clean Code with a Clean Mind

Mindfulness is a way of living in the present moment, focusing on what's happening right now. It can help you become more calm, relaxed and focused. This is an incredible skill for a developer.

• 4 min read

How to practice meditation 🧘‍♀️

It's easy to start doing mindfulness meditation. All you have to do is sit down, close your eyes, and focus on the breath as it passes through your nostrils. You don't need any special tools or props—you can use a chair if you want, but it isn't necessary. You can even practice it while walking or eating.

If you're new to meditation, this might be intimidating at first: that's why I suggest you start with guided meditation using Headspace

Code can't be clean if your mind is not ☀️

Don't think of mindfulness as a state of mind. It's about being aware of what is happening in your mind and body. If you're not mindful, then you might be distracted by external factors and we all know how a long-lasting focus is fundamental when writing code.

Having a well-defined plan on what to do will help you write code that communicates better its intentions. Living in the present will prevent you from engineering unnecessary upfront abstractions.

Writing a test list before you start writing code is another technique that allows you to focus on one thing at a time and then move on to the next.

Breath slowly and fix bugs 🐞

Breathing exercises are a great way to relax and calm down. They help you focus on what you are doing, which is essential when it comes to fixing bugs.

Sometimes we get so stubborn in trying to fix a bug we forget we should slow down, pause from hitting the keyboard and re-think the problem from a different perspective.

Next time you are debugging something without result or facing an incident, try to have 10-minutes of breathing: you will create space in your mind to come up with alternative routes to solve the issue.

Be the perfect team member by giving to others 🧑‍🤝‍🧑

Be generous with your time and resources when it comes to teaching people who are new at something as complex as software development.

Coaching is useful for two reasons:

  1. you verify your real knowledge regarding a topic and feel any gap you may have
  2. you feel better helping others and knowing you left a trace in them
  3. you get a sense of respect from the coachee and she/he will be more open when it will be your turn in getting help

Don't be overwhelmed by your code reviews ⏸️

Doing and receiving code reviews is no easy task.

When reading all the comments, don't be defensive about any mistake or issue pointed out in your codebase. Encourage reviewers to explain their comments completely so you can better understand their points of view.

Remember: they are highlighting issue on what they understood of your code, not on you.

At the same time, when reading someone else code, try to be as objective as possible and always assume good intentions. If you think they wrote inefficient solutions, try first to think why that may be the reason: were they in a rush? Didn't they know about that syntactic sugar that can improve the code? Didn't they know about the effects of this function on other systems?

Understand your emotions and when they are influencing your judgement.

Develop a habit of mindful coding ♾️

As with any other techniques in Software Development, like the art of refactoring or Test-Driven Development, you must practice getting the most out of Mindful Coding.

Starting with a 10-minute breathing exercise after 1 hour spent debugging something without results can be a nice way to introduce yourself to this new experience.

Writing the test list only after a guided meditation can be another useful association: your brain will love it!

Connect your mind before plugging in your keyboard and enjoy a focused developer experience.