This is simply my own interpretation. I deem my code clean when:
- The physical layout of the program is consistent (internally and with my other programs). Module uses (including strict and warnings) are at the top, followed by the program flow, followed by subroutines (declarations excluded), and then the end of the program. Below is POD as needed. My indentation is consistent throughout, my brace style is consistent, etc. There shouldn't be a chunk of code that looks out of place.
- All variables have the proper scope, and are declared when it is most fitting to do so.
- No code is obfuscated, and any code that is less than intuitive is commented clearly.
- The code is structured in paragraphs. I try to keep the number of consecutive non-empty lines to a sensible number. This way, comments can act as "headers" to my paragraphs of code.
Argument checking is done in most cases, and if I'm writing a module, I'll always use
Carp's functions to raise errors.
I've probably left out some concepts, but it comes down to this: would I feel confident showing my code to my fellow developers (or peers in general), and would I expect them to understand the operation of my code without me intervening?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.