4

Where can I find some references concerning when to use options and when to use multiple arguments in designing and writing functions?

Seems most built-in functions have arguments less than 3 and with a large number of options.

Are you confusing at the choice of using arguments or options?

And sometimes too many arguments which are ordered, the bad thing is that we may forget how to pass parameters with the right order. This is saying that, when using options, we don't care the order of options, just pick the ones needed.

Sometimes multiple arguments could be combined to one list argument.

Sometimes multiple arguments are convenient to be implemented into the rough/original demo functions.

Sometimes multiple arguments are more frequently used in some of my short-run functions.

Sometimes options will be added to some of my old functions, and especially long-run functions.

Sometimes options can be well inherited and translated from different functions.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
HyperGroups
  • 8,619
  • 1
  • 26
  • 63
  • here could be a start: http://mathematica.stackexchange.com/a/16615/2448 – Stefan Jun 28 '13 at 12:39
  • This is asking for opinions which is explicitly not permitted by StackExchange rules. I also think it is too broad a question, another reason for closing it. – m_goldberg Jun 28 '13 at 13:01
  • @m_goldberg well, where are such questions more suitable to be asked? Actually if someone know one book about this topic? or duplicates discussions about this topic is welcome. Sorry for my ignorance of rules. – HyperGroups Jun 28 '13 at 13:11
  • You could bring it up in chat. The rules are more relaxed there. – m_goldberg Jun 28 '13 at 13:13
  • @m_goldberg Ok, Let me try that. – HyperGroups Jun 28 '13 at 13:22
  • @Stefan good to know about such links. – HyperGroups Jun 28 '13 at 13:22
  • Actually, I think this question can be written in a way that doesn't fall out of bounds of the site. See this old question of mine for an example of a "best practices" question that was considered useful and in scope. If you can edit the question a little to read less like you are asking for opinions, then I think it can stay open. Otherwise I will close it. – Verbeia Jun 29 '13 at 03:28
  • A mechanism that I use sometimes, which isn't obvious, is to make the function all option-based: f[OptionsPattern[{a->1, b->2}] and then specify certain succinct forms: f[x_Real, rest___] := f[a->x, rest]. it's very convenient – amr Jun 29 '13 at 08:58
  • 3
    HyperGroups, I'd like to try to answer this question, but at present it is too unfocused to attempt. You list a number of considerations yourself; listing them back to you would surely not be helpful. Perhaps you could explain exactly where you are having trouble balancing these considerations, with some examples, so there is something concrete to address. – Mr.Wizard Aug 26 '13 at 18:24

0 Answers0