Re: Perverse Unreadable Codeby gregor42 (Parson)
|on Apr 26, 2001 at 18:20 UTC||Need Help??|
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!