Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

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

You are using the term "readable code" without clearly defining it. I think "maintainable code" is far more important. Some of the things that help make code "maintainable" are:

  • Sound domain abstractions.
  • Wise program decomposition.
  • Highly cohesive, loosely coupled modules.
  • Descriptive, explanatory, consistent and regular names.
  • Minimizing the exposure of implementation details. Minimizing the use of global data.
  • Minimizing the scope of variables, pragmas, etc. Avoiding action at a distance.
  • Avoiding duplication (DRY).
  • Encapsulation.
  • Interfaces that are: consistent; easy to use correctly; hard to use incorrectly; easy to read, maintain and extend; clearly documented; appropriate to your audience.
  • Useful commenting and documentation.
  • Components that are testable in isolation. Comprehensive test suites.
  • Avoiding unnecessary cleverness (encapsulating and commenting it when cleverness is required).
  • Establishing a rational error handling policy and following it strictly.
  • Logging effectively. Logging enough information to trouble-shoot customer problems without the need to attach a debugger.
  • Checking the result of all file operations, API calls and external commands, and handling unexpected results.
  • Consistent code layout.
  • Avoiding "big arse" functions.
  • Avoiding magic numbers.
Perl doesn't stop me doing any of this. Indeed, it nicely supports all of the above points IMHO. Note that a more subjectively "readable" programming language does not somehow magically prevent you from violating any of the above points. Personally, I have little interest in cosmetic issues, such as whether one prefers forced indentation (a la Python) or considers Perl's regex syntax or use of $ in variable names "ugly" or "line noise", for that is just personal (subjective) preference and has little to do with writing maintainable code.

See also:


In reply to Re^4: What's it with Perl Syntax ?! by eyepopslikeamosquito
in thread What's it with Perl Syntax ?! by biohisham

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 contemplating the Monastery: (4)
    As of 2015-07-06 00:28 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 (68 votes), past polls