I can not begin to tell how much I love a little book called “bird by bird - Some Instructions on Writing and Life” by Anne Lamotte. It has influenced my life and my work in more ways than I can list here, and this is also not the subject of this post. The idea of this post is to relate a chapter in this book called “Short Assignments” to my work.
What are short assignments? Ms Lamotte skillfully describes what happens to her when she sits down to write something. We hear about mental illnesses pulling up chairs around her, trying to be quiet but their “weird coppery breath” will remind her of their presence, always. We hear about the thoughts that begin to flood her mind, that tell about how her well of creativity has run dry, how she comes to the conclusion that she can not do anything else and thus will starve, and how her breath gets shallow. Finally, she finds the one-inch picture frame on her desk, that she put there to remind her of the idea of short assignments. All she has to do for now is write down as much as she can see through a one-inch picture frame.
When I sit down to program, sometimes my breath starts getting shallow. I, too, have my selected audience of mental illnesses, only they are not even trying to be quiet, they talk to me about how I should not be here in this high profile company in this high profile business, and that I should go back where I came from. They also eloquently read a list of programmers that have achieved so much more, while still being younger than me. Sometimes they throw in pictures of said programmers with nice cars. During that period of mental terror, I robotically switch through source files, or my email, or some webpages, until, after about 2 minutes or so, I notice this little doodle I made yesterday before I left work, an UML-ish diagram, sketching out a set of classes and their relationships, for the next tier of a system I am developing. On there I spot a box, about one inch wide, with a class name written inside of it, along with a few public functions. I notice the class does not depend on anything. And I suddenly realize, again, that all I have to do for now is write only as many tests that will establish the functionality contained in this one-inch box.
A few months ago I read a few pretty much life-changing words in David Allen’s “Ready for Anything”. They go something like this: You can not do a project. You can only do the next small physical action in a long list of actions that will eventually produce the result. I suggest you read that again. This is huge.
Is this not liberating? You can not do it. You can not write a complex software system. You do not have to resolve the huge tension that seems to exist between nothing and the end result of a big project. You can only resolve the tension between now and a few minutes later, while you look through your little picture frame, and write your test.
For me, this is the mode of work that makes me most productive, focused and passionate. I make it my primary activity to ask myself the following question, over and over again: “What is the smallest thing I can do now to advance the given assignment a little further?”. Or, more to the point: “What is the smallest thing I can test that will tell me a little bit more about the system I am developing”.
When I have neglected to pose and answer this question for a certain amount of time, I am becoming less efficient, I am stressed, and irritated. There are a few things I watch out for, to notice this as soon as possible (because after all, it does happen):
I have changed too many files since the last checkin: More than, say 5 files checked out already make me a little nervous. It means I am working on something that is probably too big for my current short assignment.
I start to comment out tests: It is ok to comment out a test to work on a single other one that has to be fixed first. It means I went too fast, but there is a threshold. If a test stays commented out for a long time, I probably became obsessive with some other aspect of the system, and I am most likely pressing my frame against my eye very hard to spot the “dead angles” that unnecessarily bother me.
I have “ok to fail tests”: I run my tests, and there is a list of tests that are “ok to fail” at the moment, and they “will be fixed as soon as….”
This is not only tedious, as I have to check the failing tests and check if those are the “ok to fail” ones or “not ok to fail” ones. Again this indicates a burst of compulsive obsession with something I have spotted at the corner of my current 2-inch vision.
Luckily, my body faithfully reminds me of what I am doing. My neck gets tense, my stress level rises, my breath becomes shallow and I become a miserable person. Until an angel dutyfully and gently taps me on the shoulder and hands me my one-inch picture frame.
The beautiful thing when writing tests is that you usually don’t have to look back. When I look through my one-inch picture frame, it helps to not have to look back. How else would I be able to focus? It helps to feel safe and not threatened. It helps to stand on a solid foundation. In my daily work, testing and test driven develpopment provides me with exactly that. If I remembered to look through my one-inch picture frame often enough, I have built up a system test by test, layer by layer, every layer as solid as the next. It is like building my own staircase, and I can safely and faithfully step on to the very next step that I have just built, and I know it will not break down. This bundles all my abilities and experience to a narrowly defined problem, and I can rise to excellence in ways I never thought possible, because I am simply not bothered with anything else. When you were last in the flow, how many thoughts were in your mind?
There is, of course, a caveat to all of this. In order to work in little tiny steps, you must disconnect emotionally from the outcome of your big project. You must also make peace with the fact that you are not doing anything special. So many people want to build that cool engine, or that cool AI or that cool system that does whatever, and they want do feel like they are doing exactly that. With attempting to do that, there comes recognition from your peers, overtime, stress, tension, broken relationships and probably an unhealthy diet. But it is special. All those things are making it special! Your suffering is your special invitation to the party. On the other hand, writing a little test that might test one or two functions of a new, say, string class does not sound all that glamorous. And it is not. It is nothing special. If you connect emotionally with your activity and with the outcome of your work, that is, if it means life and death for you if you write the 3D engine of your game over a year or two, or just a small test over 30 minutes, you will have trouble with what I have written here. The fact of the matter is, we all do nothing special. And it certainly does not make us special. All we do is little things, and we string them together, and sometimes something interesting appears. Everything else is a delusion.
For those of you who are now angry, or just delusioned, maybe this quote from “The 15 Seconds Principle” will comfort you:
You must be more interested in producing pleasurable and specific actions in present time and less concerned with past failures or future results. Your mission is just to live and create with relaxation, energy, focus and faith. In this masterful state, there is no past or future. There is just creating in the now.