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

Re: On Quality

by tlm (Prior)
on May 10, 2005 at 10:48 UTC ( [id://455509]=note: print w/replies, xml ) Need Help??


in reply to On Quality

I try to follow the guideline of "writing code to make life easier for the poor fellow who may need to debug it". That poor fellow is often me; after a few weeks, my own code begins to look to me as unfamiliar as anyone else's.

That's easier said than done, though. It takes practice to identify what will make debugging easier. For example, it took me some time to understand that the reason for avoiding global variables was to facilitate debugging, since to fully grok the state of such a variable one must, in principle, examine the code for the entire package, which can be anywhere. Once I realized this, it became clear that a lexical whose scope is a huge file is scarcely better than a package variable (aside from not being able to modify it from code in a different file), and I understood that the goal of shrinking the scope of variables is to make their fates obvious "at a glance", a goal that makes sense only to someone who knows firsthand the joys of debugging.

One implication of the "code for debugging" dictum that I find difficult to follow is to resist the golfish temptation to subject my code to multiple rounds of compression. Yes, succinct code can be clearer than long-winded code (largely because long-winded code is often a symptom of not fully understanding the problem in the first place), but it can also slide into obfuscation. Unfortunately, it is very difficult to know where to draw the line, because at the time of coding, one is so familiar with the problem that it is almost impossible to put one self in the shoes of someone seeing one's wonderfully concise gems for the first time. As I already remarked, that "someone" is often me a few weeks later.

the lowliest monk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-25 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found