Accept your arguments as a hash. | [reply] |
Your flamebait has attracted enough interesting and useful replies that I've just added it to
my list of references at On Interfaces and APIs. :)
As discussed in that node -- and as you have discovered -- the dark art of interface and API design
is certainly not an easy one to master!
> Or maybe, just maybe, you have no clue what I am doing and why I need all the variables in a single subroutine
Instead of ranting like that in an eight-level deep reply to an old thread started by BernieC,
I suggest you start a new thread clearly describing the problem you are trying to solve,
along with your proposed API to solve it.
Much more likely to elicit useful replies that will improve your initial attempt at an API.
| [reply] |
Perhaps off-topic, and I don't remember where I have this from, but ordering of parameters is partly conceptual, partly a documentation issue. The suggestion is to put the parameters in a sentence (and use that sentence always in the function help). E.g.
- search needle in haystack (this variant is probably a "false friend" for non-native speakers) → "needle" parameter goes first, then haystack
- search haystack for needle → "haystack" parameter goes first, then needle
Of course, your sentence(s) would be much longer, but once you have a "natural" phrasing, you have a "natural" order of the parameters. And, as the example shows, word use is important… This is (programming) language independent, btw. | [reply] |