Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: "Cleverness" from HOP

by whakka (Hermit)
on Jun 11, 2009 at 23:43 UTC ( #770788=note: print w/ replies, xml ) Need Help??


in reply to "Cleverness" from HOP

Am I naive in thinking you can write clever code so long as your commenting for it increases exponentially with respect to "unit" increases in cleverness? It seems to be the main reason Perl and other languages with delimiters let you write one line of code on any number of lines you choose. It's the reason for the /x flag on regular expressions, which certainly hold a fair amount of potential abuse of cleverness.

Also, "cleverness" should really be disambiguated from "obfuscation," which is a deliberate attempt to conceal the intent of code. As a simple example, $|++ isn't clever.


Comment on Re: "Cleverness" from HOP
Select or Download Code
Re^2: "Cleverness" from HOP
by chromatic (Archbishop) on Jun 12, 2009 at 08:15 UTC
    Am I naive in thinking you can write clever code so long as your commenting for it increases exponentially with respect to "unit" increases in cleverness?

    Yes; comments are far too often a maintenance burden.

    I want the intent of my code to be clear on reading the code itself. Where it's not, I try to rephrase the code for clarity. Where that's not possible, I use a comment to explain the motivation.

      Agreed. Comments should explain the why. The what should be blindingly obvious from the code.

      ---
      $world=~s/war/peace/g

Re^2: "Cleverness" from HOP
by BerntB (Deacon) on Jun 14, 2009 at 22:11 UTC

    I have a recent personal experience of this.

    Half a year ago, I did some intricate mangling of a query language. The delivery schedule was really, really tight.

    People reading my code, complained that all the comments made it hard to read. That was a first. :-)

    With less time pressure I would generally refactor code this complex, so it wouldn't need all the explanations. (Not so "clever" -- more "dense". Just an OO interface to the code's internal data structures would have helped a lot with clarity.)

    The code more or less followed Perl Best Practices, but was still an example on how not to do it... :-(

    Edit: Refactored this comment a bit, so it is possible to parse. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-07-14 03:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (254 votes), past polls