Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I can't agree more.

There have been so many times where I have been stuck sitting there knowing that what I want to do will work, but not being allowed to do it.

For a concrete example: a monitoring program which sends alerts when your server's disk starts to get full at $work. I want just a "warning" at 100% full, not a "critical", since the disk in question is very low priority and I don't want the system to cry "Wolf!" The obvious solution is to set the critical level to 101% full, and therefore it will never trigger, leaving 100% for the warning.
Naturally somebody went and made the GUI only allow 0-100% to be entered, and also require something in the critical field. Yet, if you snoop around in the database and poke 101 into the correct cell, it all works perfectly as intended. Unfortunately you can't do workarounds like that and still expect corporate support for it.

...Anyways... I would just like to say to all the assertive coders:
Please do not assert that the input is within an expected range.
Instead, assert to protect against things which will make your function fail.

Note that this is the opposite of taint checking; instead of only allowing known-good data from untrusted users, your users are now the authors useing your module. They are fully trusted (and can edit your code if they really want to), so you want to maintain the maximum flexibility while providing some convenient notification when they're about to burn themselves.

The distinction here is the difference between a guard rail on the highway and the padded rubber room your power users will require after trying to use your code. :)


PS: this, of course, only applies to modules that do not interact with untrusted users. If taint checking is a good idea for your module, then highly restrictive assertions are probably a good idea too.


In reply to Re^2: Your use of assertions in Perl ? by SuicideJunkie
in thread Your use of assertions in Perl ? by ady

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found