Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) 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!

In reply to Re: Perverse Unreadable Code by gregor42
in thread Perverse Unreadable Code by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found