Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: "Cleverness" from HOP

by ikegami (Patriarch)
on Jun 11, 2009 at 17:46 UTC ( [id://770717]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^5: "Cleverness" from HOP
by gwadej (Chaplain) on Jun 11, 2009 at 19:54 UTC

    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?

        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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-18 00:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found