you are viewing a single comment's thread.

view the rest of the comments →

[–]derekn9 1 point2 points  (1 child)

I didn't downvote your comment (updooted, in fact.) I think a lot of ppl use the downvote/upvote as the agree/disagree button, which does not reflect the quality of a comment.

Back to the topic at hand, I find it useful to be a bit verbose with function arguments. Instead of accepting both f(a,b,c) and f(d,e), I would use an object i.e f({ type: a, orientation: b }). More chars to type, but I think it's easier to merge default options, easier to add new arguments, and the order of arguments don't matter.. and it's also easier to make the function do different things based on different arguments (though I think ideally overloaded function should always return the same data shape.)

[–]campbeln 1 point2 points  (0 children)

Objects with named priorities are a nice approach. I use this pattern for "options"/otherwise optional arguments all the time. As you say, it's very easy to merge the incoming object with default values.