Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Perverse Unreadable Code

by gregor42 (Parson)
on Apr 26, 2001 at 18:20 UTC ( #75803=note: print w/ replies, xml ) Need Help??


in reply to Perverse Unreadable Code

Being a new boy to Perl I find I come across plenty of code that is so compact it is on the whole unreadable and therefore un maintainable.

Oh Brother __your_name__, at the risk of garnishing the mass disapproval of my brothers, I do contend with thee...

...If you're already interested in using English then I would suggest an alternative that is of somewhat greater benefit.

Being a Consultant myself, I write lots of code for other companies & projects that I'll likely never see again. Also I end up working on code that others have written before that, at first make no sense to me whatsoever...

So cut to the chase ... Use Comments

gregor42 ducks behind a pew for flying --'s...

What I mean by this is simply that if your are Yet Another Perl Hacker in a long chain of people who will eventually (ab)use, modify/torture, the code/project in the length of it's lifecycle, then you should put signposts on the trail.

I hate to get all preachy & sound like a COBOL-pushing-compsci101 prof or anything, but if you write profuse comments you will be doing your clients & possibly yourself a service.

As you reverse engineer how the code works you take notes & embed them in the code. These may help to serve someone else in the future; even yourself 6 months from now when you've forgotten how it works again.

In the same spirit of generosity that makes Perlmonks a Great Community, I urge you to share what you learn as you go with those who know less than you.

Yes, there's a lot to be said for style in writing code. But there's a lot to be said for using something like perldoc to your advantage to keep your comments where they belong, in the code, so they're maintained as you go, as well.

As far as deliberate Obfuscation.. Well I LOVE it. I can think of no better way to force yourself to dig through text & learn. But then again, there's a time & a place for everything & unless you're really worried about job security, you shouldn't ever use it in production code. (:



Wait! This isn't a Parachute, this is a Backpack!


Comment on Re: Perverse Unreadable Code
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-20 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls