I used to be an all-night coder, but around 20 years ago, figured out that my best hours were early in the morning, up to around 1pm. 2-4 were so-so. 4-6 were for easy work.
This still holds, though I seem to be able to work a lot longer. Kind of odd that’s happened as I’ve aged.
Yesterday, I programmed all day and into the night. What happened was that I spent most of the week doing a lot of driving and physical work. So all the tech was pushed off to the weekend.
What I noticed was that coding got harder as the day progressed – not unexpected, but it was really apparent, probably because this is refactoring some twisted old code. Early on, it was easy, as usual. I was chugging along pretty well, with a few breaks, until around 4pm. That’s a lot of coding for me.
Then, things got a little harder. Decisions became more difficult, and the easy answers weren’t coming through anymore.
By the time the windows went dark, I wasn’t sure I was doing anything just right. I mean, it seemed OK, but there wasn’t that easy sense of “yeah, all these other contingent pieces will fall together if I do it this way”.
So I quit. I spent all day on the code, anyway, and was content.
This morning, I started again, fresh. I just did a little coding here and there, spent some of the brainpower over on Facebook – probably not a great use of time – then went to fix my car and eat. Fixing the car took some brainpower, because I hadn’t ever tightened my alternator belt before. Well, not since I was in my 20s, on a different car.
Then I listed a few things on Ebay, and researched some products. Unfortunately, I think that consumes a lot of brainpower, even though, like Facebook, it is a trivial thing. It’s new information to read and learn, and that always seems to use me up.
Then, I decided to do some more coding, but, this time, more along the lines of “test driven development”. I just went into the test cases, and ran the tests, and got rid of syntax errors, for the most part. I don’t have real test cases – it’s just trivial things to test the syntax, and filling out the skeletal code.
Somehow, I knocked out three hours of coding, with no real problems, until I ran out of easy and obvious fixes. I made a lot of progress on some tedious, uncreative sections of code. So I pushed through and fixed up some harder things, until around 8pm.
It was harder, but not as bad as the day before.
I suspect the TDD-style of coding let me deal with simple fixes, and helped preserve some of my decision-making capacity. Furthermore, the consequences of my decisions were fenced in by the relative simplicity of the coding.
Do the architectural coding in the morning – the things where big decisions matter.
Do the easier “TDD” stuff in the afternoon.