Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

It is perhaps easier to describe "unclean" code. For example:

  • Code with lots of code smells.
  • Lots of magic numbers.
  • A 5000-line main program.
  • A sub that reads and writes global variables.
  • A sub that does not have a single purpose; for example, instead of a sin function and a tan function, someone defines a sin_and_tan function.
  • Some of a sub's parameters are not used.
  • A sub that is 1000 lines long, aka "Big-Arsed Function".
  • Duplicated code.
  • Code with gaping security holes.
  • Code that leaks resources.
  • Code that is not thread-safe or signal-safe.

Conversely, some clean Perl code attributes are:

  • strict-safe.
  • warnings-safe.
  • taint-safe.
  • Good variable naming.
  • Minimize variable scope.
  • Prefer lexicals to globals.
  • Good commenting.
  • Consistent indentation and visually pleasing layout.
  • Easy to understand.
  • Simple, Clear, General.
  • Easy to use module interfaces.
  • Comprehensive test suite.

Finally, TheDamian's new book Perl Best Practices provides much sound advice on writing clean Perl code.


In reply to Re: Meaning of "Clean" Perl code by eyepopslikeamosquito
in thread Meaning of "Clean" Perl code by neversaint

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (13)
    As of 2015-07-31 09:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (276 votes), past polls