Wednesday, April 07, 2010

Defensive programming, the real reason

For better or for worse I am very possessive of code that I write. When people break my code, I have to take deep breaths in order to not insult them.

Of course this has helped me better understand the purpose of tests like solo programming never could have. It's made me realize that team programming is a war. If I didn't build my tests well enough, such that someone else is able to break my code, that's my fault, not his.

If you really want to impose your will upon the codebase, write tests.

Thursday, April 01, 2010

My polyphasic story

A friend asked me about my sleeping and here is what I sent him:

There are actually two stories. For about three years I was doing a sleep schedule commonly called “Everyman” where I sleep 4.5 hrs/night and take 4 naps a day for 23 minutes. That worked very well even though previously I needed 8.5 hrs/night to be functional. I had high levels of energy  all day even until bed time. I felt basically the same whether it was 1am or 8am. It also helped improve mental and emotional aspects of my life because of the regular breaks. I started that when a coworker idly talked about it at lunch one day. Although I’ve been working at home for the most of the time I’ve been on the schedule, I chose naptimes that would work at a full time job, so it can work for people at work too.

Google has lots of information about it, often under the title “polyphasic sleep”, but lots of the search results you’ll find are people trying to document their attempts. Most people fail, but I think also that when people succeed, they forget about their blogs and never report the success. It is physically and emotionally taxing, but it is doable. Large amounts of sleep deprivation are par for the course and that causes depression, so you have to be careful. In my opinion the only reason I succeeded was because my wife was pregnant and couldn’t sleep at night, so after each nap she would stand me up and walk me around the house until I was lucid. The benefit to her was that for several months after the baby was born I was still doing the no core sleep thing. I took care of the baby all the time during the night and helped the baby nurse without my wife waking up. So my wife never had to deal with a crying baby in the night.

The other story is that since December I’ve been trying to change back to the more ambitious version which is no “core sleep”. In polyphasic sleep terms, “core sleep” is the big chunk of time that you sleep, usually at night. Going without core sleep is either called Uberman or Hexaphasic. I have not read any public accounts of people maintaining it more than 6 months, but I think it is doable. I started doing Hexaphasic when I started this whole thing and had adjusted to the physical difficulty of staying awake, but being suddenly VERY alone for 8 hrs/day and the mild sleep-deprivation induced depression made me stop.

Now that I have more experience and am more adjusted to the naps and the night time, I’m trying to go hard core. When I went to bed (on the 4.5hr/night schedule) I still had lots of energy and couldn’t stand just going to bed when I had so much energy. However, I have found that there is a world of difference emotionally between getting a small about of core sleep and no core sleep. I’m going on 3 months of trying to make the change from 4.5 to no core sleep.

If you are interested in trying it, my suggestion is to start by taking naps. I think my schedule works well: 7am (depending on when you wake up you won’t take this one to start), noon (before you eat anything for lunch), 5pm (ideally naps should be 4hrs apart, but you can fudge it a little. You should probably take this one at work to keep the fudge as small as possible), 10pm, and then go to bed when you feel like it. With that many naps, you’ll naturally go to bed later, if you find yourself staying up until 1am, take another nap at 1am. All naps should be between 18min and 25min, you’ll have to play with it to see what makes you groggy when you wake up. Too long a nap is WAY worse than too short a nap. If your brain moves into deep sleep, you very well may not wake up and your mind will be foggy. Even if you were to choose not to go hard core, you’d still have more energy all day and more awake hours. While you are trying that you can read stuff on the net to see how far you want to take it.

So that’s me spiel. As you can tell, I enjoy the topic quite a bit.