Why make the job harder by adding a large pile of additional potential typos?

There are always cranks to complain about everything. That doesn't mean you shouldn't try to do things well. Someone will complain no matter which side of the utensil drawer your spoons are on, but that doesn't mean you should throw them in randomly.

When things get a bit more complicated, then you add to the data structure. Instead of a simple hash of lookups, have a hash of hashes which include the lookup value and a type. When you have a one-off exception case, add a new type, and handle that. If it isn't a new type of thing, then you trivially add it to the list of things to check instead of copying a block of code.

This is what requirements and experience are for. Keep it simple with a fixed block and save time now, or make it flexible as an insurance payment now to protect against future additions. For best results, keep the flexibility options in mind while you write the simple case, and make it modular enough that refitting flexibility in later is as easy as tacking an elsif condition on. Either way you go, you don't need to repeat yourself if you use the right data structure.

You don't have to compromise quality or maintainability on this one.


In reply to Re^4: Improving if statements by SuicideJunkie
in thread Improving if statements by Anonymous Monk

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.