When creating an API, I always try to be as friendly as possible to the 'user' (the programmer using that API). So usually the best option is to support as many type of arguments (object, separate values...) as you can. Also, try to be permissive with the order. For example, if you build a join() function, support join(array, string) and join (string, array). If you want people use your API, try to be as easy to use as possible.
Anyway, if you have to choose A or B, Fran's rules are very good, IMO. -- S.Cinos JavaScript Developer at Tuenti.com 2011/1/13 Nick Morgan <[email protected]>: > On 13 January 2011 18:26, Poetro <[email protected]> wrote: >> >> Support both. >> > > I was going to say exactly the same thing. If you only need two arguments at > the moment, use two arguments. If you need to expand later, make it so the > function can optionally take a single options object. This doesn't have to > break compatibility because you'll check the number and type of the > arguments. > -- > Nick Morgan > http://skilldrick.co.uk > @skilldrick > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
