Hacking Your Way Through Codebases

You’ve joined a new project, and you’re trying to fix a bug. You try to make sense of the classes, how they interact, what they abstract.. Looking at the design documentation, you realize that they’re older than your son. Previous project members seem to be vacationing in dense jungles in Zanzibar.

It’s a weekend and you’ve nothing to do. So you decide to add that feature you always wanted into your favourite open source library. You check out the SVN trunk and try to figure out where to start hacking away.

Does any of this sound familiar?

That “software development” involves more reading than writing of code, comes as a surprise to many industry newcomers. Books and university courses teach how to design, implement and test software. How to model, simulate and measure systems. How to design, analyze and improve algorithms.

Yeah, well. You don’t start off your career like that, kid. First, you get to make tiny fixes. Which requires you to go through a lot of code, figure out how the entire damn thing works, pinpoint the exact root cause of that sporadic bug; and then use all your education to make the most minimal code change possible to get rid of that bug. Oh, and the bug appears only when there are more than 50,000 people accessing the 4-million-row database table simultaneously, so don’t think about attaching your cute debugger and stepping through the code. Did I say it was sporadic?

If you pass out of the university having read nothing but the example code listings in the text books, then be ready for a rough time when you join the industry. Even if you’ve written your own nice little software. Because reading code is very different than writing it.

You can really judge how good a developer is be seeing how he responds when asked to fix a bug in a codebase which he’s seeing for the first time. The response is either of “what? in that? i didn’t get a knowledge transfer session for that!” or “by when?”.

So how do you do it? It’s many things, but mainly it’s experience and tools. “Ah, so you’ve a box of magical tools!” Well, no. You tend to end up using only what’s generally available, on most platforms and that too by default. Things like ctags, vim, grep and a debugger. That you’ve learned to use really well. But mainly, it’s the experience, and the intution and patience that comes with it.

The best reward of reading code is that you get to learn more from that than from textbooks. Ever seen how a Hindley-Milner system looks like in code?

Go read code. Grow up.


  1. Chintan said,

    Jun 19, 2008 at 10:15 pm

    Yeah, thats what I realized when I joined last year in embedded s/w industry. Loads of code, code repositories, code written in 90s. till now I have not written more than 100 line of code ..

    One humble suggestion, blog more frequently

  2. Jul 3, 2008 at 12:42 am

    […] Read the article at the Tired Architect’s blog titled “Hacking Your Way Through Codebases”. […]

  3. Arun said,

    Jul 14, 2008 at 5:20 pm

    Could not agree with you better. I can still recall my initial programming days when ALL we did was debug programs written by “Senior” programmers. I think the first step to being a better programmer is to spend time and uderstand the code that is being developed. When we joined the IT industry we did so because we loved programming and it was much more than ajob to us. But these days the attitudes have changed; no one wants to program for more than 1-2 years – Everyone wants to get into “management” and in the process lose track of the fundamentals…

  4. himadri said,

    Mar 2, 2009 at 11:35 pm

    wow , you amaze me by your wisdom …you really need to write extensively and spread the goodies …
    I could not agree more with your points …
    we are in an industry where the learning never stops …
    you need to be a voracious reader to be able to keep pace ..there’s so much going around .. so much books and blogs written ..reminds me of something I read in philip greenspuns site …the internet has revolutionized everything and made this knowledge acquisition accessible to all ..

  5. Manuj said,

    Nov 16, 2010 at 8:07 pm

    But just beware that you are not doing these small fixes throughout your entire lifetime(which is unfortunately what software industry in India is all about)

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: