Deepak Surti
  • Blog
  • Mobile Apps
  • Projects
  • Graphics Demo
  • Me

The digital diary of a
​programmable programmer!!!

It's probably harder to read code than to write

12/24/2011

1 Comment

 
I came across this piece by Joel, where he says ”It’s harder to read code than to write it”.

PERFECT. Atleast my programming experience matches with what he says. On the other hand, I do not interpret it as ’so just stop reading code and do something else’. If you have to do real programming, you have to spend time ’understanding’ already written code.

Now, the deeper reasons for why it could be hard to read code could be:
  • To read code, you need to have a purpose. That purpose is defined by any feature, typically, a bug fix or an enhancement task. But any feature does not use all code. So you will not read all code.
  • Next, it is humanly impossible to read all code of any application (Have you ever)? In fact I have not even completely read all the code of any application that I wrote completely! Let alone all the code, you will not read all code related just to the feature you are working on.
  • Reading code without input/output information is a mindless task. It is not productive and does not make sense. This is because input/output information gives meaning to code without having to infer it, which otherwise is hard, error prone and cumbersome.

Here I have found my detective utilities (here , here) very handy. It eliminates the futility of reading code as it helps me ’understand’ code relevant to the feature I am working upon as it provides:
  • Code trace relevant to a feature (I start, stop detective)
  • Code information such as input, output, argument names and time spent

With the information provided by detective, I can explain the code in business terms to someone else while pointing to function names. Thats it. I have learnt the lesson the hard way.

So if Joel says ”Its harder to read code than to write it.”, we now have a corallary:

”Never read code without contextual information.”
1 Comment
Tamilselvan Rangasami
5/15/2015 02:16:22 am

Great Advice. Thank You. And Dtrace is Cool.

Reply

Your comment will be posted after it is approved.


Leave a Reply.

    Picture

    Me

    I am a 3D graphics software engineer.

    profile for dmsurti at Stack Overflow, Q&A for professional and enthusiast programmers

    Archives

    December 2011
    November 2011
    October 2011
    September 2011
    August 2011
    July 2011
    June 2011
    May 2011
    April 2011
    August 2010
    January 2010
    December 2009
    September 2009
    August 2009

    Categories

    All
    Books
    Code
    Continuations
    Css
    Drakma
    Education
    Express Card
    External Drive
    Html
    Ita
    Learning
    Life
    Lisp
    Mac
    Macros
    Mercurial
    Puzzle
    Reading
    Rss
    Simplicity
    Sudoku
    Work

    RSS Feed

    Picture
    me @ delicious
To see a miracle, be the miracle
  • Blog
  • Mobile Apps
  • Projects
  • Graphics Demo
  • Me
✕