Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Write "Dumber" Functions

by FoxtrotUniform (Prior)
on Apr 01, 2002 at 17:04 UTC ( #155801=note: print w/ replies, xml ) Need Help??


in reply to Write "Dumber" Functions

Who was it that suggested the "Principle of Least Surprise" for component behaviour? I'd say this is a rather gross violation of that rule. Sure, it's great to tell the programmer that they may have called the function improperly, but to die on ill-formed input, especially in a function that's supposed to check for validity, is extreme. (By all means carp about strange input -- bonus points if you provide a flag for debugging output, so that end users don't have to wade through a huge cascade of "hey, programmer, I think you've messed up" messages from a smart-ass module.)

As an aside, I can't stand the name 'check_date' for that function. Okay, it checks the date, but what does it do after checking the date? Die with an error? Return true ("yes, it's valid")? Return false ("yes, it's bogus")? Set a flag somewhere? How about is_valid_date instead?

--
:wq


Comment on Re: Write "Dumber" Functions

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://155801]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-12-18 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls