Sometimes people who have a problem to solve can do amazing things when they aren't encumbered by knowing the "right way" to go about things.

I was looking over such a piece of code last night. Someone needed a web interface for running tests cases, and put together a web server that would serve up HTML, images, and run Java test cases and return the results (in HTML). All in 61 lines of Perl. Granted, it was hardly a complete web server. It worked off of the first line of the HTTP request, and returned a minimal (but correct) response header. Some of it looked like raw socket code lifted out of the Camel book. No strict, no modules (other than Socket), and only one comment. Still, it solved someone's real problem in less than page of code.

Looking it over, I got to thinking about some of the people who wander in here with real problems to solve. We usually advise them to use strict, use CGI, and reuse some set of modules from CPAN. Instead of a minimal script that'll solve their problem, they're sent off with a shopping list of things needed to build a "correct" (i.e., heavier) solution. And often these solutions require fresh CPAN downloads to install elsewhere, which raises a real barrier in some situations.

The problem with the "right way" is that it's a slippery slope. Do I really need an XML parser if I'm given a simple chunk of XML to deal with, or are regexes sufficient? Do I really need a database for a simple content management system, or are would flat files work adequately? Do I really need to use CGI if I'm doing something simple inside the firewall? The "right way" adds weight that isn't always needed.

But many of us are inclined to do things right. We know that today's requirements are incomplete and will probably grow anyway, and that we'd better plan for the future by building solider solutions than are asked for, leveraging tested, off-the-shelf code where possible to save effort.

I suspect, though, that this leads many of us to over engineer the occasional one-time problem we encounter.


In reply to Simplicity vs. Doing It Right by dws

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.