Managing stress by working with your hands

After a long day of coding and problem-solving, it’s hard to calm down and relax. A major part of a programmer’s job is working in our heads, being in the flow and handling a ton of details at once. But how to relax your brain for a while so you can keep working at peak performance in the long term? And how can you recharge so you have the energy to take on personal projects?

In my opinion, one of the best way to do this is to build routines and habits in your day that allow you to work with your hand and that does not require staring at a screen. Working with your hand is active but allows you to let go for a bit while still feeling productive. You’ll produce a concrete and visible result from your effort, which is good for the soul after a day of chasing some abstract bug.

My intention here is not to add tasks to your plate and make you feel even more stressed out, but to help you find practices that will give you more energy. It must not be yet another chore or that would defeats the whole purpose!

soupe2One of my key habit I suggest is cooking your own supper instead of buying takeout. I don’t do it every night, but most days I cook a meal and save the leftover for lunches. I know it’s easier to call for pizza or grab a sandwich, but cooking is a creative outlet that will allow you disconnect and relax instead of rushing dinner and going back to the computer.

The French have it right with their late dinner: just eat a snack in the afternoon if you find you can’t wait for dinner. As a bonus, you’ll get to eat food that’s better suited to your tastes and to your body. An heavy meal like pizza or pasta will sap all your remaining energy. If you cook, you can optimize: make a lighter meal so you have more energy afterwards.

If you’re not attracted to cooking, any manual hobby is good for relaxing: for example, you could take up woodworking, gardening, drawing, playing an instrument, home improvement or beer brewing. If it makes your hands move and it does not involve a computer, it’s a good bet that it will help to relax. It will also bring a new perspective to your coding since you’ll be solving different kinds of problems.

weavingIn my case, I’m into fiber arts in general and hand weaving in particular. It’s interesting to plan out how a piece of fabric will turn out and execute it with a very limited of options: there are only 4 pedals on my loom. Making the fabric itself involve repeating a pattern regularly without loosing track: it requires concentration and getting into the flow. It’s different to tracking down an hard to find bug, unless a thread breaks…

If your favorite hobby is not very physical, you should add activities in your day that allow you to move a bit more. I’m not the best at strenuous physical exercise, but biking, taking a walk or doing a few yoga poses can do wonders to recharge and get more energy.

Learning to work with your hands will require some efforts from your part: it won’t necessary be relaxing and mindless at first. You’ll get frustrated at first trying to master the movements required. If you want to get better at those hobbies, you’ll also need to mix in more challenging tasks from time to time. But when you get the hang of it, you’ll be able to get into the flow and work at it effortlessly like coding.

Do you already have an hobby that allows you to work with your hands? I’d love to hear all about it!

Sign up now to receive my latest musings about the craft of software directly in your inbox.

How to maintain the habit to learn coding skills

TreadmillManaging to find time to improve your coding skills is hard with all the other obligations you have to keep up with. You don’t want to burn out: you need to maintain a social life, spend time with your family and have time for a few hobbies away from the computer and get some exercise in.

When you do get some time at the computer, it’s hard to focus your attention on just one thing and learn it properly: they’re always a brighter, shinier language to learn or a project that’s cooler than your current one. If you’re to believe all that’s said about being a good programmer, you also have to know many software design patterns and how to implement them, contribute to an open source project and master complex computer science concepts to stay up to date and have a chance to keep your job.

In fact, very few people know how to do it all, and people who have extended knowledge in multiple subjects have worked at it for many years. For example, I don’t fashion myself as being a master of web programming, but I’ve been paid for the first time to develop for the web in 2004, so of course I had more time to pick up knowledge, techniques and tricks that someone that’s totally new at it.

You have to learn new things and stay up to date, but you don’t need to know everything to do good work. Learning a new language or a new framework can be done in a few months even if you don’t have a lot of free time, and you don’t need to be on the treadmill at all times: it’s OK not to want to learn a new framework every few months. But what can you do if you do want to learn that new language? Where can you find the discipline you need to improve your skills in a real and profitable way so it does not end in a disappointment?

Discipline does not matter as much as having good learning habits and strategies. Discipline is really hard to maintain: you monkey brain will always want to try out new things, and then make you feel disappointed that you abandoned your cool project. Habits, on the other hand, will help you build your skill in the long term. So, here are a few steps to help you build the right habits:

  • First, you have to commit to a main learning project that’s the one to wish you’re going to apply all these strategies to, be it a programming language/framework, a computer science concept, a coding project or even a soft skill. If you spread yourself out too thin, you won’t make enough progress for it to be interesting and useful. Choose something you care about and that you’re interested in learning: don’t choose something to focus on just because it’s popular online right now.
  • Plan out where you want to go with this project, including a rough outline and a clear stopping point. If you have a reasonable time horizon for your project, for example a few months, you can reevaluate where you want to go when time is up. If you feel you want more, you can keep going for another chunk with a new set of goals. If you don’t, you can stop guilt-free because you accomplished what you set out to do.
    For better effectiveness, you also want to plan the few next steps so you don’t have to think about it to get started. When time is short, you don’t want to waste half an hour pondering what you should do. That plan should include tasks that work for various energy levels, like finishing a tutorial, reading the next chapter of a book, listening to a course or a related podcast, or have a few features ready to code.
  • To keep making progress, you need to work at it a bit everyday on your project even if it’s something small. You’re not forbidden to work on other things, but your main project should get a bit of your time first before you work on anything else. Slow and steady wins the race: if you only go at it when you have hours of free time available or when you feel the stars are perfectly aligned, you won’t work at it often enough to make a real difference. Also, it’s easier to immerse yourself in a new concept if you keep working at it, even if it’s only a little bit each time.
  • If you’re in purely for the learning, you need to let go of the idea that the project must be 100% finished. Enjoy what you learned on that project and take it with you for the next project. Some programmers have a pet project like a TODO application or a blog that they like to implement in each new language they are learning to get the hang of it: it doesn’t mean that each of those projects have to be production-ready and bug free. And besides, even software in production is never really done anyway.

Learning is a lifelong quest for a programmer since there are always new skills to master, so you need to learn to enjoy the journey. For each new things you learn, you’ll find many more that you want to improve, so don’t forget that you’re only human and that you can’t do it all.

6 ways to code faster and with less bugs

Fast typing It can take ages to code what looks like a simple feature at first glance. Times flows while you have the impression that you made no measurable progress on that new feature and that everything is hopeless.

Outsiders will tell you that you’re only adding a checkbox or a text field and wiring stuff together, so it should not take this long. Why are you coding so slowly?

Thinking about the time it took to create a new feature as the number of lines of code you need to produce is a mistake, because the part that takes the most time is not typing code in the computer. Your keyboard shortcut skills are not going to help you with all the other things you must do to create the feature like:

  • Understanding how it needs to behave when it’s done,
  • Looking at the existing code to understand where it fits,
  • Choosing the best controls and API methods for the job,
  • Naming and documenting the variables and methods in your code,
  • Testing the feature.

Indeed, I’m not going to give you tips to type code faster or technical shortcuts since those can be found in any technical book about your language or framework of choice. Likewise, there are many great posts about keywords shortcuts and tools for your IDE of choice.

So here are some ways to optimize all the other stuff so you can deliver faster:

  • Make sure you understand what the feature should do properly before you start coding, including those hairy corner cases that you must handle. Things can change, but you’re going to lose a lot more time if you code something and have to start over: aim to do things right the first time.
  • Plan out the big picture of how you are going to implement the feature and what are going to be the names of the most important classes and methods. This is the hardest tip in this article to stick to, but you’re going to be a better coder if you make it an habit to read the existing code to get a better idea of what to do and plan for the most probable pitfalls before writing the first line of code.
  • Break down what you need to do in tiny wins instead of trying to take it in all at once. Doing just one small method at the time and incrementally adding more code as you go on is easier to manage than trying to do everything you’ll ever need in one shot. Ideally, you should always be able to run the application even if the feature is not complete. Don’t be afraid to leave TODOs in the parts of the code that are not done yet so you’ll remember what you wanted to do when you come back to finish it.
  • Make sure that each tiny part is well-formatted, with good names and properly documented. It’s easier to do while you’re writing the method instead of waiting to do it all in the end, and chances are that once you’ve moved on you’re not really going to fix it. This will make it easier for you to use the method and change it as needed since it’s already nice and clean.
  • Keep a piece of paper or a notepad beside you as you code to jolt down things that comes to mind as you work. While you code, you’re going to think about things like test cases, that bit of CSS you need to adjust and how to implement other parts of the feature. You can take a quick note without breaking the flow of what you’re doing and go back to the current task. That way, you don’t need to keep all those things in your head (think GTD) and you’re not going to forget them all if you get interrupted.
  • Don’t hesitate to look for examples of code when you don’t know how to do, but avoid copy-pasting. Rewrite those examples using your own variable names and standards, and take ownership of it by understanding it as well as code you wrote yourself so you can fix it if something goes wrong. Also, if you have bugs and don’t understand what’s going on at first glance, use all the tools at your disposal like reading the docs for the API methods you’re using, using the debugger and inspecting the code of your page to make sure it’s behaving as you expected. There’s no need to try to be tough, examples and tools are there for a reason.

All those techniques will also help you with writing code that has less bugs since you’ll know where you are going. Coding more deliberately will help you make the best of your coding time and deliver better features.