Agreed. The hash of options is much cleaner and should be considered
if extending the parameters of existing functions. (And would be
employed in the core if we were writing TiddlyWiki from scratch
today).

Martin

On 19 May 2011 13:45,  <[email protected]> wrote:
> On Thu, 19 May 2011, Martin Budden wrote:
>
>> (Note that adding parameters on
>> the end is OK, at least in javascript (as long as an 'undefined'
>> default value is assumed)).
>
> I'd like to see this habit change. It makes for very noisy method
> signatures. I much prefer (in javascript at least) the policy of
> passing 0, 1 or 2 required parameters, and then everything else that be
> option as a dict/hash. A tidied up version of this:
>
>    var foo = function(req1, req2, passed_options) {
>        var options = {
>            bar: 'hello'
>        }
>        if (typeof passed_options === 'undefined')
>            passsed_options = {};
>        $.extend(options, passed_options)
>        // actual code
>
>    }
>
> This is much more readable and maintainable than:
>
>   TiddlyWiki.prototype.saveTiddler =
> function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created,creator)
>
> It makes it possible to add and remove parameters without changing the
> method signature, keeps things on one line, allows for easy defaults
> and parameter checking and is generally just more tidy.
> --
> Chris Dent                                   http://burningchrome.com/
>                                [...]
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/tiddlywikidev?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en.

Reply via email to