Home > Real Life > Priorities


At my place of employment, I recently had to blow the dust off of about 900 lines of Python code I wrote for one-time use (so that I can use it a second time). Joking aside, the process has actually been both cathartic and frustrating. See, the code was built to run once, not to be pretty or maintainable or particularly efficient. (Quote from my boss: “As long as your machine doesn’t smoke, it is not a bad idea to start [the program] up at the end of the day and let it run.”)

But on a geek level, the same geek level that wanted to implement yesterday’s quicksort three ways for kicks, I want the code to be clean. Six different classes all read in file data in mostly the same way; it would be possible to use inheritance to remove the file I/O code that I copied and pasted from one class to another, which would probably reduce the whole project by 100-200 lines.

But it’s really not necessary. The code runs, and the file reading is so dead simple that it will never need to be changed (hah!), and so I never get around to it. In short, to quote myself in a message back to my boss, “It’s kind of embarrasing to see how little best-practices code I used. I might rewrite this on personal time, just as a mental exercise in remembering what fast-and-dirty code looks like and how to avoid it.”

Now, make no mistake, the indication of willingness to do this in off-time makes clear that this is simply trying to write beautiful code. However, I can’t help be reminded of this ordeal when I read this:

Busy Productive
Rolls their own Uses someone else’s
Makes it “elegant” and “extensible” Makes it work
Responds to your email within a few minutes Responds to your email within a few days
Ready. Aim. Aim. Aim. Ready. Fire. Aim.
Makes the boss happy Makes the client happy
Seeks consensus Encourages creative self-expression
Writes a detailed specification Implements a prototype
Looks like they’re busy Looks like they’re slacking off
Finishes it this evening Finishes it tomorrow
What else can we add? What else can we remove?
How should we fix this? Do we need to fix this?
Sees the toolchain as a competitive advantage Sees the user-kickassness as a competitive advantage
Let’s get everyone’s feedback on this DO IT

And really, I think I’m just humoring myself. After all, as the man says, the world is full of interesting problems to be solved, and none of them should have to be solved twice. This problem is, quite really, solved. When I have so many other software projects to work on, and ones I’m purposely ignoring, rewriting this “throw-away” code just wouldn’t be right.

Categories: Real Life
  1. arnuld
    April 29, 2008 at 12:59 am

    I am not sure but I think rewriting that code can make sense or non-sense. It actually dependds on the context. See this scenario:

    I am sure there must be some ideas on which your 900 lines of code in Python is based, like understanding inheritance properly and then making good use of it but that is just one example. Many programmers make poor use of the concepts. I have seen lots of programmers writing Desktop Applications in C++ and they never ever use vectors, Heck, they don’t know anything about vectors.

    Same in your code. If the fundamental concepts you used in writing that code can be learned and then be applied in some other piece of code, at some other point of time, then there is no point in rewriting it. It is the understanding the problem at hand and then designing a solution within the constraints and features of the particular language that is important. Using language’s features according to its design ideas, understanding the issues like using a particular Data-Structure for solving a particular set of problems while using others for some other problems, is what that distinguish a good programmer from a bad one. It is not easy though as it takes years of experience to do such geeky things 😉

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: