Coding Zen


Coding Zen

by Daniel Pratt

Coding is all about creating and solving puzzles.  No two puzzles are exactly the same, and sometimes one puzzle requires you to invent several other puzzles in order to solve the first puzzle.  I think this is what appeals the most to me about programming.

Sometimes, however, when I go about solving one of these puzzles in my code, I start going about it the wrong way.  It's hard—for me at least—to get off that track, and try something completely fresh.  I start to obsess, being consumed with solving the problem, but unable to see it completely from another angle.

Oddly, instead of being frustrating, it starts to fuel me even more, and I keep plugging away until something forces to me to stop.  When I come back to it, I usually solve the puzzle I was spending hours on in a matter of a couple of minutes.  Even knowing the logic behind letting the problem breath for a little while, I still used to have a hard time stepping away.  I usually would need at least an hour or two away from my project to be able to come back to it again from a fresh enough perspective to solve whatever I stumped by.

One day, I decided to combine coding with my daily meditation practice.  Whenever I am stumped, I meditate.  Not only does this work as a great way to get myself to walk away for a little bit, I find that the perspective change I was looking for can come from a five minute meditation break, rather than spending a few hours doing something else.

Anyone who has any experience with meditation knows that one of the things you practice is identifying when you are being pulled away from the focus of your meditation.  You might start to have your thoughts wonder off, or get distracted by some background noise, which is fine, but you get really good at identifying and naming your distractions immediately, which helps your mind guide itself back to what you are focusing on.  For example, if your mind wanders you have your inner voice say, "thinking, thinking" as soon as you realize it is happening.

This trick works really well in everyday life, as well.  So whenever I find myself getting obsessed with a tricky puzzle in code, I will tell myself "obsessed, obsessed."  This allows me to extract myself from my coding, and I can start some meditation.

If you have never meditated before, it's worth trying out.  A simple, but powerful, meditation technique is called "breath meditation."  It only involves one thing, you paying attention to your breathing.  You don't try to control it, you just notice that you are breathing in, pausing, breathing out.  When you get distracted, you just name your distraction, and allow your mind to naturally come back to the breath.  You don't judge your distractions, you just notice that they happen.

You don't have to be a programmer for meditation to help in your daily life.  Try it out.

Comments

  1. The meditation part I can skip right away, but your comment about "stepping away" is actually a good one. I felt in similar ways when I would make a break, e. g. jog and run about for a while and suddenly the problem is a LOT easier.

    I think that this partially has to do with the way how humans interface with computers. Computer sorta make you dumber. Sure, there is a lot more information about there but I feel that the brain gets handicapped by the computer.

    ReplyDelete

Post a Comment

Popular posts from this blog

Passing Information Between View Controllers

Save the Internet

Landing Your First iOS Developer Job: My Journey Changing Careers