DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,547 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Learning to code with mindfulness
BigCityC
BigCityC

Posted on

Learning to code with mindfulness

I have recently noticed a peculiar habit in my day to day coding. I often find myself feeling frustration when I can’t solve a problem right away. This creates an urgency to complete the project, and results in unorganized code and half thought out solutions.

When I have felt frustration in the past with a problem, my go to habit was to just start coding the first solution that pops into my head, and hope that it works. More times than not, it doesn’t.

Last week I started to become more aware of when I am feeling frustrated. Recently I have been practicing different techniques to help put my mindset in a better, more calm, place when setting out to solve a problem.

Technique 1: Turn off distractions
Now, when I prepare to code, I turn my phone all the way off, close my email, and disable anything else that may distract me during the time I choose to focus on a problem. This technique helps me retain focus on one thing at a time and helps keep my mind clear on what needs to be solved in the code.

Technique 2: Map it out
This technique has changed the way I approach coding. Now, when I feel hints of frustration, I know it’s because I need to step back from the keyboard, and create the space I need to really understand the problem at hand.
This is the two step process I use to more mindfully solve problems:

  1. Write out HOW the code currently works, and how I want the code to work.
  2. Brainstorm all the possible solutions to the problem and choose the best one.

I bolded the how in step one because that is the key to solving problems. When I let frustration get ahold of me, I try to solve the problem by asking WHAT I need to do to make it work, and not HOW to make the code work. Asking β€œwhat” is a surface level question, and often does not address the underlying problem, while asking β€œhow” forces you look at the problem from its most basic level, and work your way up to the specific problem.

In conclusion, I have been using the combination of removing distractions and creating space to think more carefully on how a problem can be solved. These two techniques have helped me code more mindfully and be more focused while solving problems.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.