I don't like the 'it seems to work' school of program analysis, unless it is backed up by a (by definition) complete set of regression tests.

There is such a thing as defensive coding.

i.e. Parsing a config file.

while( <FILE> ) { s/#.*$//; # Lose comments s/^\s*//; # Lose leading w/s s/\s*$//; # Lose trailing w/s next unless $_; ... do stuff }
This will function fine (modulo bugs...the above is just typed). It will continue to function fine if you remove the w/s stripping lines and the set of test data doesn't contain any lines consisting of only w/s.

However, if you do that and then someone adds a line containing w/s to the config file then it will barf. Of course, if your environment defines that failure in that case is acceptable since that is not a legal line in the config file then you have done nothing wrong.

IMHO, a (small, controllable) bit of over-engineering is OK, if done sensibly.

Then again, there are always cases where this would be the wrong thing to do. So shucks, its not a universal rule.


In reply to Re: Over Programming by jbert
in thread Over Programming by little_mistress

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.