How to Practice

In my previous two blog posts (here and here) I mentioned practicing. The posts cover the reasons why we should practice, but they don’t mention how to practice. Here are some resources for that:

Google code katas. These are sample programming problems that you can solve over and over in any language. They aren’t about solving hard problems, they are about practicing and forming good habits.

Similarly, google koans for your language of choice. These may feel like beginner tutorials, but they are about practicing until you have the nitty gritty details of your language committed to muscle memory.

exercism.io offers guided programming problems with pre-written tests for many languages.

The Pragmatic Programmer recommends learning a new language every year. This is great practice even if you don’t get to use those languages in your day job. Try to pick languages in a different paradigm than what you’re used to. This will often help you see better solutions to problems in any language. You can use the previous resources to learn these new languages.

For meditation, google for a mindfulness mobile app so you can have it anywhere, and as a little reminder every time you look at your phone. I use The Mindfulness App on iOS. I like it because it offers both guided meditations in different lengths, as well as meditation timers I can set to any length of time I want. Great for starting out with 1 or 2 minute meditations.

There are many ways to practice, these are just a few suggestions. However you do it, remember the goal is to train so that when the pressure is on, you default to good code instead of bad.

Meditation as Training

When we train for something, it’s to form a habit. We want some behavior to become instinct. We want to do it without having to decide to do it.

Meditation is practicing focusing your mind on one thing and nothing else. Usually it’s your breathing. It’s training to bring yourself back from distractions, to be present and mindful of the actual surroundings and not the surroundings as you wish they existed. To put your full attention on what you’re doing right now instead of what you want to be doing even ten seconds from now.

That doesn’t mean you never think of the future. It means you’ve trained so that when it’s most important to be in the moment – which is when you’re most likely to not want to be in the moment – your instincts will kick in and you will handle it.

For example, you need to get some feature out ASAP. Here’s two scenarios for doing that:

Scenario 1) You hammer out a solution. You’re thinking about code, sure, but only enough to get the characters into your editor. Your mind is really on the goal: shipping this feature. You run the code and… it doesn’t quite work. Oh, you just need this quick fix. Still doesn’t work. Quicker fix. Still doesn’t work. Agh! Because the goal is just barely out of reach and it feels like it’s moving away from you, you go faster. Quicker and quicker fixes. It finally works! The code is garbage, but it works, and it took way longer than you thought it would. So you back away slowly and don’t touch it (ever) for fear of brining down that house of cards.

Our brains default to this scenario. It takes training and practice to fix this problem. Google mindfulness meditation and read up on it. A great way to start is by counting breaths: In, out, one. In, out, two. In, out, three. Go up to ten, then go back down to one. Repeat. When you do this, your mind naturally starts wandering: thinking about what you should be doing instead, all the tasks on your plate, that stupid thing you did in the past. This is the part you’re training for: realize your mind is not in the present. Don’t get frustrated that you can’t seem to meditate “right”. Acknowledge that thought. Maybe even sit with it for a couple seconds, and then let it go. Bring yourself back to the breath. If you lost your place, start over. It’s not about finishing, it’s about the process.

If you make this a habit and practice it daily, it will help you the next time you start feeling stressed. Your breath becomes a trigger to bring you in the present so you can do your best work.

Start with 1 minute. It’s very easy to tell yourself you don’t have time to meditate, but everyone can spare 1 minute. When a minute becomes habit, try two. Then three. I’m only up to four minutes myself and am already seeing huge benefits.

Scenario 2) In this scenario you’ve trained for this. Your stress at the beginning of the cycle becomes a trigger and instead of going faster, you stop and focus on what you’re doing right now: I want to get this feature out. Ok, that’s a thought about the future. Acknowledge it and let it pass. What am I doing right now? I’m writing this line of code. Now I’m writing this line of code. Now this line.

In the first scenario, it felt like you were moving faster, but because you were focused on getting somewhere faster, you wrote bad code, which actually made you get there slower. I’m willing to bet the second scenario got you there in roughly the same amount of time, but with much less stress, and an end result that has less bugs, and is more maintainable.