From the project
Programming insight that helped unblock me
I'm finding a big part of the context switch involved in getting back to a high level of productivity on my programming is relearning old lessons.
In particular one of the most important lessons is to figure out how to systematically break down different goals into separate steps in a way that allows you to concentrate your full brain power on each of those steps in succession rather than trying to get it all done at once.
For instance, being a perfectionist is a bitch. I don't want to write ugly code! But writing code that works is hard enough. Writing code that is both beautiful (read: elegant and easy to understand) and that works is a bit overwhelming. Trying to engage my mind on two different goals at the same time either locks me into paralysis or reduces my productivity dramatically as my brain constantly switches back and forth between these two goals without getting that much of anything done.
So the trick is to do it in two steps:
- Write ugly code the works: Give yourself permission to write a chunk of code that is sloppy, ugly, in the wrong place, etc. Your full brain power is concentrated on just getting it to work (I.e., pass the next test).
- Make it pretty: Refactor it so it's pretty (e.g., easy to understand, small and elegant, small) while making sure you don't break your test.
Presto: good code that works.
You still have to be careful how much ugly code you write. If you go too far you may tie a knot of tangled complexity too difficult to break without a full re-implementation.
Note, I don't think I'm breaking new ground here. Just deepening the existing paths.
http://www.flickr.com/photos/55972691@N05/sets/72157625280045279/detail/