Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Complexity of API argument passing

by TheoPetersen (Priest)
on Jul 13, 2001 at 23:39 UTC ( #96556=note: print w/ replies, xml ) Need Help??


in reply to Complexity of API argument passing

My opinion is that a routine should be generous and intelligent in handling arguments, to a level which matches its code "audience." If you are the only one using the routine, then you can set this to your tastes; obviously you wouldn't spend much consideration on it if it were being used only in one script in one place, but the more places you use it the more you'll invest in making life easier for calling scripts.

If the routine is being used by other programmers, the requirements for generous argument handling jump immediately. You should process all sensible input arrangements so long as those arrangements don't compromise the routine's efficiency. I personally dislike any mechanism that requires a caller to pass arguments that tell the routine what other arguments are being passed, preferring things that can be deciphered via ref() as you mention.

I definitely don't go to multiple front-end functions for a routine unless I'm in a maintenance situation where I can't change the input handling of the target routine. I do use such arrangements where I need different output formats, though, if the output format can't be determined just on the basis of wantarray.


Comment on Re: Complexity of API argument passing
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2014-08-27 19:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (250 votes), past polls