When I'm writ­ing code, and build­ing some­thing com­pli­cat­ed, there's this place I usu­al­ly get to where I'm about to write "the hard line of code". Usu­al­ly, I've just fin­ished set­ting up a bunch of code to ag­gre­gate the da­ta I need both to read and up­date, get­ting the locks I need, and oth­er house­keep­ing chores, and now I're go­ing to write the com­pli­cat­ed bit of arith­metic or re­al­ly sub­tle con­di­tion­al that's go­ing to com­pute the out­come val­ue or de­cide whether to in­clude the record or what­ev­er the goal is. I al­ways pause in­vol­un­tar­i­ly and lean back. Then one of a few things hap­pen­s:

  1. Most of­ten, I re­alise that I haven't got my da­ta mar­shaled or re­sources locked or house gen­er­al­ly kept prop­er­ly, so I have to back away and go back and do some refac­tor­ing. The les­son here is that you of­ten don't re­al­ly un­der­stand the prob­lem un­til you write the code. This is true both at the macro lev­el (y­ou can't ful­ly un­der­stand the us­er re­quire­ments un­til you start writ­ing the code) and at the mi­cro lev­el (y­ou can't ful­ly un­der­stand the da­ta mar­shalling re­quire­ments un­til you write the one short se­quence of code that us­es it al­l.
  2. Quite of­ten, I stop and go get a cof­fee (or write a note like this). The ac­tu­al rea­son for this is pure bone-laziness, my brain re­alis­es it's about to be asked to re­al­ly stretch out for a mo­ment and in­ter­pos­es a dis­place­ment ac­tiv­i­ty. But I'm not sure it's a prob­lem, of­ten when I'm get­ting the cof­fee I sud­den­ly re­al­ize that I'm ac­tu­al­ly in sit­u­a­tion #1 and I'm not quite ready to write the code.
  3. I just write the code. But al­most nev­er with­out re­course to one or both of the pre­vi­ous step­s, some­times mul­ti­ple times.

author · Dad · software · colophon · rights
picture of the day
January 28, 2003
· Technology (81 fragments)
· · Coding (98 more)

By .

I am an employee
of Amazon.com, but
the opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.