On Fri, Jan 14, 2011 at 21:16, Garrett Smith <dhtmlkitc...@gmail.com> wrote:
> On 1/14/11, Andraž Kos <andraz....@gmail.com> wrote: > > On Fri, Jan 14, 2011 at 02:59, Garrett Smith <dhtmlkitc...@gmail.com> > wrote: > > > >> I would remove that comment and rename that from "args" to something > >> like "options". > >> > > > > term came from C language and we all know where args are born: command > line. > > > When I see "args" in javascript, to me, that sounds more like an > arguments object or maybe an array. I prefer "options" or "config". To > me, those sound like an object with optional properties used for set > up and configuration. > -- > There is a simpler common sense reason to always use an Object for all params: Why do I have to look 3 times an hour into some nazi API while debugging to figure out why to specify terms exactly like this: runbad(bar,foo) if there is no common sense reason to keep the order the same way some unimportant wannabe "god" said 5 years ago? PHP is evil in this sense, do we have to drag same bad practice around in the next generation? runme(args) can be called: runme({'x':bar,'y':foo}); or runme({'y':foo,'x':bar}); or var setup = {'y':foo,'x':bar}; runme(setup); or var setup = {}; setup.x = bar; setup.y = foo; runme(setup); and it's self documenting because it's obvious from the code. If I have to use some library that doesn't enable me to switch params around I'll write my wrapper for the bad API: var runme = function(args) { if(args) { if(args.x && args.y) { runbad(args.x,args.y); } } }; -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com