Tilly and brian d'foy best stated the theory for balance between feature and maintenance. But to add some more concrete decision points to blahblahblah's comments, consider this:

Advanced features of a language really best serve one of three purposes, and usually only one at a time.

  1. performance increase
  2. readability increase
  3. obfuscated code entry

In the first case, it goes without saying the performance increase needs to be noticable, not just measurable to be worth the effort of cluttering the code with complexity, let alone the effort of even working out the code in the first place. Then, it should be heavily documented including what the "simpler" code would have looked like in the comments.

In the second case, advanced features can actually make code EASIER to read if done right. Unfortunatly your sample is hardly that. reference = grep, if and map is hardly adding any clarity to the issue. If done right, advanced coding features and techniques can actually **HIDE** code complexity from all except those who really need it. In other words, make the code readable as in a "Coding by Intention" sort of way and leave the complex parts hidden in subroutines that only need to get looked at if you are debugging that actual segment. This leaves the mainline of code more clear. After all, loops come with a certain amount of clutter also (counters, test conditions, etc).

The third case is of course irrelavent to the discussion of production code :-)

Production code is not the place to educate the masses. Neither is it a place for needless obscurity. While many of your points I believe are valid, this particular code sample does not qualify. I think your philosophy is valid if tempered with the rules above and those mentioned by blah-cubed.


In reply to Re: "advanced" Perl functions and maintainability by KeighleHawk
in thread "advanced" Perl functions and maintainability by geektron

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!
  • 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:
    & &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.