Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-20 Thread Ariya Hidayat
One of the best advice I got was "Code is written once but read many times". This particularly holds for public API and thus I often compromise more on the readability side rather than code size or verbosity. Beside Garrett's example, my favorite classic of the so-called "Boolean trap" is: fo

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-20 Thread Peter van der Zee
On Thu, Jan 20, 2011 at 11:34 AM, Gregor wrote: > But this shifts the programmers task to "remember the property names". > /** * @param {Boolean} a * @param {String} b * @param {Object} options * - x:int=0 * - y:int=0 * - title:string="" * - onClick:function=null * - onClose:function=nul

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-19 Thread Nicholas C. Zakas
auyet Sent: Wednesday, January 19, 2011 7:49 PM To: The JSMentors JavaScript Discussion Group Subject: [JSMentors] Re: JS API Design - Accepting Parameters Andraž Kos wrote: There is a simpler common sense reason to always use an Object for all params: [ ... ] runme(args) can be called: runme({&#

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-14 Thread Andraž Kos
On Fri, Jan 14, 2011 at 21:16, Garrett Smith wrote: > On 1/14/11, Andraž Kos wrote: > > On Fri, Jan 14, 2011 at 02:59, Garrett Smith > wrote: > > > >> I would remove that comment and rename that from "args" to something > >> like "options". > >> > > > > term came from C language and we all know

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-14 Thread Garrett Smith
On 1/14/11, Andraž Kos wrote: > On Fri, Jan 14, 2011 at 02:59, Garrett Smith 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, t

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-14 Thread Andraž Kos
On Fri, Jan 14, 2011 at 02:59, Garrett Smith 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. If you are familliar with unix philosophy of programming ( http://www.faqs.

[JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread jdalton
I took a combo approach on a recent project: https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L81 // I allow `fn` because test `fn` is required new Benchmark(fn); // or a name first because other devs require a name too (an options object for just a name is bulky) and... new

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread Garrett Smith
On 1/13/11, Arlo wrote: > This group is the best thing that happen to the internet since > broadband! You guys are awesome! I definitely appreciate all > feedback and I am taking everything into consideration. What I really > need to apply from this discussion is type checking, jQuery came up

[JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread Arlo
This group is the best thing that happen to the internet since broadband! You guys are awesome! I definitely appreciate all feedback and I am taking everything into consideration. What I really need to apply from this discussion is type checking, so that param1 can be an object or a string depen

[JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread Jorge
On Jan 13, 5:37 pm, Arlo wrote: > I am developing a JS API for my employer and I constantly ask myself > how I should accept params into my methods.  So I figured I would ask > the professionals. > > Here is my scenario: > 1.) I know a handful of basic methods that I need to implement right > now.