Archive for April, 2007

TDD and Negative Splits

Friday, April 20th, 2007

Taken by http://www.flickr.com/photos/matt_alt/As a sometimes cross country and track runner, I was taught and quickly learned that the best way to run any longer distance is to do the second half faster than the first half. In distance running, we call this negative splits. Those of you who have run negative splits know how different it feels from “positive splits” where you run the second half slower. When you finish a race in which you run negative splits you generally finish more quickly, feel much better, and are excited about running the next race. When you finish a race with positive splits you feel wiped out, beaten down (by everyone who managed to do negative splits), and uninspired. Although there may be and probably are physical reasons for these results, much of it is definitely psychological. If you spend the first half of the race conserving energy and then the second half passing people, it doesn’t matter that much that you spent the first half further back than many others. As you begin passing people the psychology of lots of small wins kicks in and really makes you feel good.

But negative splits are hard to do. When the gun goes off your adrenaline is already racing and you want to win. You don’t want people to pass you left and right while you run conservatively. Even when you know through experience the benefits of negative splits, it’s easy to get caught up in the moment and start too quickly. Or it may just be that the race leaders seem so far ahead of you that you have to go faster or lose all hope of remaining competitive. Pride may drive you to run faster earlier. Or it might be a justified fear that by trying to run negative splits you actually start off too slowly and never make up the time.

In the past couple months as I’ve started practicing test driven development of a new feature that I own, I’ve felt very much like I’m in the first half of a distance race. I know that I’m progressing slower than I have in the past, if you simply measure my progress in writing code that will ship. I can feel that I’m taking longer to do what I’m doing. However, I also feel like I’ll be able to complete the feature faster, which mostly means that the bug tail will be much shorter. Looking at the code I’ve written vs what I’ve done in the past I know there is an improvement. The daily process of writing tests, and then writing code that makes them succeed is as addictive as passing people in a race and keeps me excited about the end result, even if I’m moving slower by some measures. At the same time, I feel like a better developer, I’m able to make changes more quickly, and I’m more excited about my work.

Moderation and Measurement

Tuesday, April 3rd, 2007

Moderation is a quality that I would say I lack. The Oxford English Dictionary defines moderation in this way:

avoidance of excess or extremes in behaviour; temperateness, self-control, restraint.

The specific example I’m thinking about at the moment is eating. Although I’ve never been fat, I have definitely been prone to eating more than is healthy. Around the holidays I would get sluggish, cranky, and apathetic because I filled up on junk food and didn’t eat anything healthy. During the rest of the year I ate healthier (out of site, out of mind), but still ate too much. As my life has become busier and I haven’t made time to run on a daily basis, that meant I started to gain weight. While it was slow gain, after a few years the pounds add up and I was having to buy clothes that were a different size. I felt fat, though I know I didn’t necessarily look it.

During the time I was gaining weight I became acutely aware of my problems around the holidays - they just weren’t fun when I felt drugged up on chocolate, sugar, and grease. So, immoderately, I forswore candy and chocolate. Initially, I wasn’t sure how long I could keep it up, but as the weeks and months passed I gained a sense of self-control that I had never had before. It felt great. Of course, I had to put up with my wife heckling me because now she had to eat all the chocolate and candy and knew it wasn’t healthy for her. I also didn’t eat some of the things she loved to make for me. And when Christmas came around again, she struggled to come up with treats to fill my stocking with. Besides all this, she wasn’t sure whether to be proud in public situations when her husband declined candy or chocolate, or to be embarrassed.

I ultimately kept up the chocolate and candy ban for over a year. Why did I go back? Well, when it came down to it, living without chocolate and candy wasn’t very fun. However, about a year later I knew it was time for a change again. I couldn’t seem to enjoy chocolate and candy in moderation. But I could abstain completely, or risk going overboard. This time I only banned candy, and kept it up until I started trying to lose weight. Then I promised myself I could eat as much candy as I wanted once I hit the bottom of my target weight range, and do so as long as I was within that range. But after just a couple months of that I was reminded (again!) of how crummy it made me feel, no matter how much I weighed. So I’m off candy again. So that gives you an idea of my problems with junk food.

Now back to losing weight. You might imagine that when I noticed that I was eating too much I would start fasting until I hit my target weight. It sure felt like, because I started Weight Watchers, and that reduces your caloric intake (well, mine anyway) by about half. Fortunately, I didn’t take it too far (hunger is very powerful), but was able to get down to my target weight in about three months. As I did that I developed the habit of checking my weight on a daily basis. I know that this is more frequently than necessary, but it gave me motivation each day when I was hungrier than normal.

Now, almost six months later, I’m still well within my target weight range and I’m able to eat pretty much what I want. The key, I’ve found, is the daily measurement. By doing that it’s easy to see over a week or so, if I’m starting to head up and to correct course. For me, the daily measurement is just enough incentive. And because I’m doing it, I feel very free to eat whatever I want (candy excluded for other reasons). So I have no qualms chowing down at a restaurant or filling up when Kami makes my favorite food.

The key to my success in keeping the weight off, so far, has been daily measurement. So I’ve been thinking about what it means to use regular measurement as an aid in developing moderation. Of course, my daily weighing is more than just measurement - it is a negative feedback loop. If my weight starts to creep up, my natural desire to stay on target moves me to restrict my eating a little bit to fix the problem. Because I’m measuring daily “fixing the problem” is fairly easy to do, and doesn’t require a lot of self-control or discipline like the initial weight loss did. Tight negative feedback loops are how nature is able to moderate its processes, and the same is true for us humans.

One trick to setting up effective negative feedback loops to moderate our own behavior is tuning the feedback to our weaknesses. For me, just knowing how my weight is changing, combined with my natural desire, is enough to move me to start tightening my intake. However, I know that I need something more powerful if I want to attempt moderation in my candy eating. I would need the feedback to make me quickly and significantly unhappy in some way, or I’d just keep eating.

Another trick is to make the feedback come automatically. If I have to do too much to get the feedback I need, I’ll just tend to avoid it so I can keep eating candy (or whatever it is). Fortunately, weighing myself was done on a daily basis and became a habit. It didn’t seem directly related to eating food, so I didn’t have any desire to avoid it. It worked out well for me. In general though, I think this can be very challenging when it comes to personal habits that we want to moderate. It tends to be easier to abstain completely or indulge completely.

For certain habits and certain people a tool like Joe’s Goals might be just right, though it does require some work to record how you did on a daily basis. Ultimately, though, I think the real gains are going to be in areas where you can find a way to make the feedback more automatic, and the feedback response the correct strength to make the change happen. That said, I really need to wrap this up so I can go invent a machine that will shock me every time I eat more than one piece of candy in a day…