Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: "Cleverness" from HOP

by gwadej (Chaplain)
on Jun 11, 2009 at 14:57 UTC ( #770668=note: print w/ replies, xml ) Need Help??


in reply to Re^2: "Cleverness" from HOP
in thread "Cleverness" from HOP

I think of the quote as more of a cautionary tale than a logical argument.

From my personal experience, I have learned that those truly clever and amazing pieces of code that I and others have written always seem to take an extraordinary amount of brain-power to understand and debug later.

I've also found the quote as useful for making entry-level programmers reconsider their latest masterpiece. Thinking about what it will take to debug a complex system can be a useful antidote to an overly complex design.

G. Wade


Comment on Re^3: "Cleverness" from HOP
Re^4: "Cleverness" from HOP
by ikegami (Pope) on Jun 11, 2009 at 17:46 UTC

    I'm not sure I buy the premise that being clever is hard. To be clever is to avoid thinking of the consequences of writing the clever code. Thinking things through is hard.

    I accept both of the following

    • Writing clever code will result in making your code harder to debug.
    • The harder the code is to write, the harder it will be to debug.

    But I don't see how they are related except in effect. I definitely don't see the causal relationship you posted.

      Much of the clever code I've seen in my career was more complicated or obscure than necessary, not just written without an eye toward consequences.

      An example may help explain what I see as clever code.

      A couple of years ago, I worked on a system where a programmer built a lazy-loading system with built-in cache to make certain that we didn't load the data from disk unless we really needed it. Finding when and where data was read and written was a huge amount of effort. When I eventually talked to the original programmer, I was told that we needed to do this because we might have 10,000 data points. Unfortunately, these were 4-byte data points.

      40K was nothing compared to the data we were working with. Despite that fact, several programmers over a period of about a decade had had to fight with this clever code that protected us from unnecessarily loading data.

      In another place in the code, I ran across an N^3 algorithm that had worked fine for 5 elements, but didn't seem to work too well with a couple of hundred elements.

      The first example was clever, the second did not consider consequences.

      G. Wade

        Are you saying he would still have gone ahead with his clever load-on-demand scheme if he had spent a minute to realize that saving 40,000 bytes doesn't warrant the complexity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://770668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-10-25 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (145 votes), past polls