Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^5: "Cleverness" from HOP

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

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

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

Replies are listed 'Best First'.
Re^6: "Cleverness" from HOP
by ikegami (Pope) on Jun 11, 2009 at 20:11 UTC

    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?

      I suspect that the programmer in question became enamored with his solution and did not consider whether or not it was warranted. This seems to be one of the hallmarks of clever code. The programmer spends much time and effort because he's found a cool new technique or because he's impressed with his solution.

      I guess for me, the difference between clever code and code that uses advanced techniques is very much whether or not the problem requires the extra complexity.

      G. Wade

        I suspect that the programmer in question became enamored with his solution and did not consider whether or not it was warranted

        Exactly. Focused on his solution, no thoughts or foresight about anything else. This is what I said that you seemed to contradict.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://770754]
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-01-24 06:22 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (203 votes). Check out past polls.