Home > Uncategorized > Filler: That Feeling of Dread You Get When You’re About to do Something Stupid

Filler: That Feeling of Dread You Get When You’re About to do Something Stupid

February 21st, 2009

One problem I frequently run into while writing a bit of code is that, while I have The Way The World Should Be mapped out in perfect detail, and I can see all of the possible links and interactions, I will have trouble encoding those ideas in tests because, well, ChildWindow really has to be able to call methods on TopLevelWindow, even though this necessitates a circular dependency which is bad and so on and so forth. (this particular example is kind of lame, but I hope it carries the point)

By this point, I haven’t even actually started coding anything, and I am already feeling squeamish about actually doing it. I have two options: pace around, think, and maybe talk to the smartest guy within arm’s reach about it until an appealing structure presents itself, or I can stop being such a bitch and write the code that gets the job done so that I can get paid.

By now, I have run across the circular reference problem enough times to know exactly what happens if I take the “suck it up” approach: Testing ChildWindow now requires that I construct a TopLevelWindow (which is a much heftier class), which slows my tests down and bloats my test boilerplate. If the objects in question are not implemented in the same language, it is very easy to create a memory leak in this way, and let me tell you, tracking down a reference leak created by a cycle between C++ and Python objects sucks to track down until you’ve done it a few times. (PROTIP: if gc.get_referrers(o) returns an empty list, your object is being kept alive by something that is not a Python object. This, unfortunately is the happy path for such a scenario)

I think I have a pretty good handle on this particular “oh shit this can go south” situation, but I am always on the lookout for more, and I am very glad for that feeling of dread I get whenever I am about to do something stupid.


  1. February 21st, 2009 at 20:43 | #1

    Andy gets the best pick of smartest guys because he has long arms. :(

  2. February 24th, 2009 at 02:48 | #2

    I know what you mean about getting bogged down by theory vs reality! Chad seems to have mastered not sacrificing theory, but for mortals like me, I think the answer is “pairing.” I have a really bad habit of going all meta and trying to think everything through before even touching the keyboard. Just having another warm body there to smack me and say “get back to work” does wonders.
    I do find it funny that you, Andy, are saying that you have this problem, because you’re my go-to guy for getting _out_ of this kind of problem :)

Comments are closed.