Editing chapter 5 some more
[themediocreprogrammer.git] / chapter05.md
1 # A day's journey
2
3 ## Riding until dawn
4
5 Programmers are always trying to find new ways to be productive. Tweaks to text editors, compilation tweaks, scripts and automation; the list goes on for how programmers want to maximize their productive time coding. We also spend time tweaking the rest of our lives with the belief that we should always be doing something related to coding. Any moment we're not coding is a moment where our projects get behind. And getting behind with our coding can lead to other problems: missed deadlines, other companies getting their program to market before us, or other instances where we miss an opportunity. We're constantly worrying that we're not doing enough to succeed.
6
7 We've heard the stories of developers waking up at their computers to the strange sound of beeping because they fell asleep at the keyboard and the keyboard auto repeat can't handle any more input with their face resting on the keys. Isn't that how developers should work?
8
9 There's a tendency to think that because we work with machines that are tireless and ready for more work that we need to behave in the same way; we need to constantly utilize these resources. We try become like the machine; tireless and always ready for more work. 
10
11 There's a problem with always being "on". When we feel like we always have to be "on" we never let ourselves feel like we can be "off" again. We don't allow ourselves the time to be off. This creates a pattern where we deny ourselves the moments to sit and reflect on what we're doing.  We force ourselves to keep moving; keep programming no matter the personal cost. Our brains don't get the ability to rest, relax, and recharge. Our minds are too busy and exhausted to process what we've learned and sweep that knowledge into long-term storage. When we get exhausted we start to worry that we're not doing enough. This doesn't motivate us; instead we create a vicious feedback loop of fear and panic. We spend our day worrying that we're not doing enough while our minds cry out "enough!" from exhaustion. This feedback loop of fear and exhaustion can spiral us into a vortex of burnout, depression, and a desire to leave programming for good.
12
13 There's a delicate balance that we need to strike between our desires of being on all the time and our needs for relaxation and reflection. Our desires for invincible and indefatigable development need to be tempered with the reality that our bodies and minds have finite resources per day and must be allocated appropriately. Think of this as power-management for a complex machine that the manufacturer (currently) won't let you swap the battery out for a new one. Being aware what processes are running, how much energy is being used, and how much energy is left would be vital to ensuring you could still be running that machine later on in the day. That's the level of awareness that we'll need to have about ourselves.
14
15 How do we balance these feelings of wanting to be on all the time while allowing ourselves to relax and reflect on what we're doing? How do we pay attention to the needs of this programming machine?
16
17 ## Lights out
18
19 First we need to acknowledge that we can't be on all the time. You may know this intuitively and think "yes, of course" but knowing is not the same as doing. We need to have a periods where we are not programming and not thinking about programming. We need to have moments where we can turn off the programmer part of our being. These periods of not-programming are vital to our well-being and give us chances to explore the wider world and let our minds rest in-between programming sessions.
20
21 This can be tricky if we feel like we're falling behind in our learning. When are we supposed to learn all of the new things happening daily? When are we supposed to catch up on all of that technical debt you've been accruing over the years? When will we have time to learn the ins-and-outs of technologies that aren't part of our day-to-day work but are still interesting to us?
22
23 These feelings that we have (that there's more to do and that we need to spend every waking moment doing it lest we fall behind) isn't helped by programmers who look super productive. These are the programmers that think of a clever idea in the morning and have a working prototype in the afternoon (while still handling normal work routine). When we compare ourselves against these programmers we wonder if they ever take time away from the computer.
24
25 We can acknowledge that we have feelings of wanting to push ourselves to keep learning and doing. We can see ourselves when we think "just one more line of code before bed" or convince ourselves "I  can read a few more articles or pages or [insert favorite way to consume more information here]". We can pause and see where these feelings and thoughts come from and understand why we're still pushing ourselves beyond exhaustion.
26
27 These feelings usually stem from a sense of inadequacy. We feel like we're not measuring up to the ideals we have; whether these ideals are ones we've created or ones that are externally driven. These ideals come from analyzing other programmers (colleagues or folks we admire), and measuring our progress against their work. They also come from our own mythical idea of what the perfect programmer is.
28
29 What we need to realize is that those ideas of what makes good and perfect programmers are fantasies. They're a composite of what we think a good and perfect programmer should be. They don't exist in the real world. True, we may see programmers out there that seem to wake up with a keyboard attached to their hands, spend the entire day coding, and go to sleep with dreams of more code formulating in their heads. But we need to realize that we're only seeing one side of their lives. We're not seeing the whole picture of who they are. We need to focus on our own bodies and minds and realize when they're tired and need rest. We can't make ourselves into other people, we need to work with who and what we are. 
30
31 Our bodies require down-time in order to be most effective. We need moments where we can step away from the keyboard and allow ourselves to wind down and relax. Our minds are not designed for constant work, especially at the levels that computer programming requires. The sooner we realize we should step back and take breaks throughout the day to recharge ourselves the happier (and more productive) we will be.
32
33 ### FIXME
34
35 ## Taking a break
36
37 Taking a break is more than just flipping to another application. I know my tendency for taking a break is to start checking email or head to one of the various chat programs I have in order to catch up on what's happened since I last took a break. But this is not really taking a break as it is trying ti multi-task at my desk. Real breaks require getting up from the computer. It doesn't have to be a large break;  taking a break can be as simple as standing up and walking from your workspace into another room or area. But you you need to stand up from your computer from time to time and get a "context switch" (where your mind can feel like it isn't in the same place as it was earlier).  It gives your mind the ability to completely switch out the context of the area you're in and allows it to focus on the new context and new input.
38
39 This can be tricky in an office situation where the expectation is that one must be at their desks in order to be productive. And there are only so many "bio-breaks" someone can take in such situations. How can you give yourself the context switch your mind needs in such situations?
40
41 You might be able to achieve the same sort of context-switch by looking away from the computer display for a few moments. It's a good idea to look away from the screen every now-and-again to give your eyes a rest. Giving your mind a rest while you give your eyes a rest can give you the incentive to do both.
42
43 Standing up can also be a good context switch where you give yourself more of a context-switch from the physical location of the computer. Telling yourself that there's two contexts around your desk: the context of sitting at the desk, and the context of standing at the desk you might be able to use that as the context switch and rest that your mind needs.
44
45 If you have a culture in your workplace that allows you to step away from your desk and walk around that would be a great context switch. Adding a physical component (as much as you can) to your context switch can help your mind to relax and recharge.
46
47 You'll have to experiment with a few of these and see what works. At the bare minimum you'll want your mind to feel as though it doesn't have to be on all the time. You want your mind to cool down between coding sessions so it can flush it out of "cache" and into longer-term storage. Then when you get back to your coding session you'll be more likely to remember what was going on.
48
49 ## Productive thinking
50
51 Next we need to realize that productivity is not a constant. There are days where we will find ourselves generating remarkable levels of code and code quality and days where we'll be lucky if we can string together a coherent comment string. We have varying levels of energy and mental focus available to us per day. It's up to us to look at these levels and understand what our productivity might look like for the day. 
52
53 Understanding these swings of productivity can allow us to better gauge whether or not the day will allow us to generate the code that needs to be generated, but there's a level below that I think is important.
54
55 We make attachments on completion and hitting deadlines. Some of these are external: the project dependencies require that we need to get this done by a certain date and time. But many of them are internal deadlines that we've set for ourselves. We set a goal for ourselves that we will be this productive by the end of the day. The unstated condition of this that if we aren't that productive we'll feel guilty and ashamed. We'll fee unworthy of the task at hand. We'll feel like our day has been wasted and wonder if we're capable of doing anything at all.
56
57 It's better for us to get rid of deadlines wherever possible. We won't be able to get rid of the external ones where folks are waiting on our contributions (though we may want to renegotiate those if they're not hard deadlines) but we can let go of the desires to release this project on an arbitrary deadline.
58
59 ## Containers
60
61 We should replace soft deadlines with the commitment to work on a particular project for a given length of time. One trick that I have found useful is the idea of a timed container where one chooses what they are working on and then focuses on that project with their full attention for the period of time. I've used 10 minutes but something as small as 5 minutes or as large as 25 minutes can be useful. The work we selected at the beginning of the container is the only thing we work on, and we do our best to make sure there are no interruptions, whether internal or external, until the container is complete. When the work is done we wrap up wherever we landed and then take a quick break before starting the next container (with the same or some other task before us).
62
63 When we start the container we see where the session takes us. There is no judgment of the quality of the work in the container, just the expectation that we will work  for the duration of the container. There's also no expectation about what we will have accomplished when the container is finished. If we complete the task before the container ends then that's awesome! We can then figure out what out next task will be.  If the container ends and we're still in the middle of debugging a problem perhaps we write down where we left off and what steps we took in order to get there and then work on something else. Or we get up for a bit and come back to the session in progress.
64
65 The underlying concept for the container is just to agree to work in the container without judgment for the work done and for the progress made. When the work is done in the container we take a step back and reflect on what we did and where we need to go. We give ourselves permission to not have to worry about it in the moment, but also allow ourselves the freedom to look back in short increments and see how we're doing. We allow ourselves to just work in the moment without fear of judgment, reprisal, or self-recrimination. We give ourselves the gift of uninterrupted work (or at least as much as we can possibly give). And we give it our full attention by turning off notifications, closing other programs, and focusing on the work in front of us.
66
67 ## Distractions
68
69 Life is often full of distractions that are beyond our control. Someone walks up to our work-space and needs our attention at that moment. An email thread that we thought was settled becomes a heated discussion and needs our attention. Something happens at home and now our minds are split between work and home. Whatever the cause may be there are times when our attention isn't where we feel it should be and we feel pulled in every direction at once.
70
71 This is where the containers can be most helpful. If someone interrupts the container we can determine if it's something that is more important than the work we're doing. If it is more important than what we're currently doing we can stop the container with the understanding that we'll get back to it once we've handled the interruption. If it's not more important then we can agree (both with whomever is interrupting, or ourselves) that our focus needs to be here, with the work, until the container ends. We'll be able to give that other thing our full attention and not try to split our attention between the two.
72
73 This may seem like a simple delineation but putting it into practice can be challenging, especially if the culture you're in is about immediate results.
74
75 I don't have good answers if your culture demands your attention at all times. The best I can offer is that the containerized approach at least gives you some periods of concentration. But if you feel constantly on-guard because something might happen at any moment you're going to be less effective than if you have the ability to shut the world off for a bit. I'd also challenge you to see if that perception is really true: are you constantly being ambushed by interruptions? Testing that theory may be in order. Keep a sheet of paper (or put it into a text file, spreadsheet or database) with when you did a focus container and if it was interrupted or not. If you find that you are getting interrupted more often than not then you need to reassess what is causing the interruption and if it's something that you can control. There are many ways to handle workplace distractions that I won't go into here but being mindful of the distractions and where they are coming from will be key to figuring out how to mitigate them in the future.