Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I think it's no great use making guidelines in general. You'll have to agree on guidelines in one project and it's good to have concrete ideas. The actual decisions will depend on the group.

Some of the things you mention are in my eyes means of sane programming (system calls, exit code). I don't think you can work seriously with someone who has to be told these things. Also, I'd never say "SHOULD". Say "MUST", so first of all there is no doubt: "Use strict! No exceptions. That's it." Someone who _really_ knows when to disable strictness, will do it. Someone who doesn't will struggle for a solution and ask for help and then someone else may tell him "This is the exception, you may disable strict here."

So there are some general rules i'd make (and in general i agree with you):

  1. use strict! Always.
  2. use warnings! Always.
  3. Doing CGI? use CGI.pm! Always.
  4. Parsing commandline options? use Getopt::Long and Configure() it POSIXLY_CORRECT! Always.
  5. check system calls! Always.
  6. Use comments to comment, use POD to document. Don't mix these two.
  7. Avoid Globals!
  8. Globals are all variables with a scope that is larger (in the sourcecode) than an average screen.
  9. Name Globals wisely. Follow perlstyle rules
  10. Use spaces to make things clearer

These are the rules I consider "general". Other things are matter of personal taste but should be equal inside a project:

  1. open the curly on same line as keyword. Indent next line.
  2. closing curly on single line, indented as deep as keyword of opening curly.
  3. curly-rule exceptions are special short blocks (map,grep,sort)
  4. No space between function name and opening parens.
  5. No space between array identifier and opening square bracket.
  6. No space between hash identifier and opeing curly

Now finally the Tab-issue: I really think that one should use tabs, but only for indentation. Don't use tabs for alignement.

if( $a > $b ){ T---return T---T---cond1 ? val1 : T---T---cond2 ? val2 : T---T--- default T---; }

This way your alignement won't break in someone else's editor using a different tab-width, but logical indentation is still present. I am really convinced that this is a solution.

--
http://fruiture.de

In reply to Re: My coding guidelines by fruiture
in thread My coding guidelines by Abigail-II

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 having a coffee break in the Monastery: (7)
As of 2024-03-29 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found