Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Understanding this code

by sundialsvc4 (Abbot)
on Sep 28, 2015 at 14:10 UTC ( #1143246=note: print w/replies, xml ) Need Help??


in reply to Understanding this code

My simple advice to you would be:   “This is Golf.”   As in, “write-only code.”   Simply re-write the damn thing into something that you, and any and everyone else who will in due time follow you, can understand and maintain.

(Incidentally, I would say this about any such piece of code, no matter who the author was, and I would also not be speaking personally against the author in saying this.   To me, it is simply an engineering question.)

I believe quite strongly in “The Glance Rule.™”   Source-code should be written in such a way that it can be reliably and accurately understood “at a glance,” by anyone who is moderately(!) versed in the language.   If the reader has to “puzzle out” the meaning of the code, however briefly, or to post a question on PerlMonks seeking explanation, it should just be rewritten.   Such code often turns out to be rigid, costly to maintain, and sometimes actually slower.   Dozens of people over an equal number of years might touch that code before it is retired, if ever it is, and they are usually doing so in order to change what it does, not to fix it or further improve upon it.   “Code accordingly.”

Replies are listed 'Best First'.
Re^2: Understanding this code
by GotToBTru (Prior) on Sep 28, 2015 at 14:47 UTC

    If you can't understand it, how could you re-write it?

    This code might possibly be daunting at first glance, but someone moderately versed in Perl would have no trouble parsing it. This is practically self-documenting. "Record all the values between the value of an element and the value of the next one, for every element in the array (except the very last)."

    Dum Spiro Spero
      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2019-10-23 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?