Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

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

In the latest edition of Joel On Software, Joel pulls out a Larry Wall quote:

People understand instinctively that the best way for computer programs to communicate with each other is for each of the them to be strict in what they emit, and liberal in what they accept.

Joel makes it pretty clear that he thinks this is a stupid idea. Frankly, so do I.

Why is Design By Contract considered such a good idea? Because a very explicit contract exists between the client and the server: I, as the server, tell you, the client, exactly what you're allowed to give me and and I promise that, in return, I will do X. (If you're interested in this with Perl, try Class::Contract by Damian Conway).

Some people would argue that this violates the spirit of TIMTOWTDI. No, it doesn't. Nothing in the contract makes any guarantees how I implement my solution. Nothing in the contract specifies how you have do what you want to do. It merely ensures that when different portions of a program interact, they do so on a very, very predictable basis. Imagine working on a huge system where you have many virtually identical object methods that take a scalar, or an array, or an array ref, or a hash_ref using named parameters but won't accept a hash, etc. What interface do you use? And what if the data structure returned seems to be arbitrary? I've worked on systems that do that and they are Not Fun.

One of the best examples of this problem is the Web browser. Netscape won't render tables that leave off a closing table tag. This is a Good Thing. Internet Explorer has once again tossed standards out the Window (hah!) and decided that you, the developer, don't know how to send a correct Content-Type. Instead, IE examines the beginning of your entity body and it decides how to render it. Have you ever wanted to send HTML as plain text? That's a non-trivial task if you're using IE. More than once, I've sent an "image/gif" that was actually a jpeg and tried to figure out why IE rendered the image and Netscape didn't. IE tries to hold the programmer's hand and, as a result, takes away fine-grained control -- though it's still one of the best browsers on the market.

How could these problems have been avoided? W3C standards are, in effect, a variant of Design by Contract. You know what you have to send and, in return, you know exactly what to expect. I've heard so many Perl programmers moan and groan that standards aren't being adhered to, but fail to appreciate that what products like IE are trying to do is be liberal in what they accept.

So, I think Larry is right in the sense that being liberal in what to expect is a worthwhile idea. Very few people can get it right, though, which is why I think Larry is wrong.


Update:: I think my point was not as clear as I thought. As I said below in a reply to tye, it's "not that we should be so rigid that we break with the slightest gust of wind. My point is that we shouldn't be so flexible that we fall over." It's that middle ground that most fail to find, so I'd rather they err on the side of caution :)

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

In reply to Larry vs. Joel vs. Ovid by Ovid

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, 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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (7)
    As of 2018-03-20 08:47 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (248 votes). Check out past polls.