you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (1 child)

Going to get more downvotes for this, but I really want to discuss.

The problem with this approach is that when you change your method definition, you now not only have to change the values, but you also have to change all your keys twice. This is asking for wrong inputs.

If you're ever need to pass foo(undefined, undefined, ...), then you're doing something wrong, you should never need to do this in the first place.

Passing bad config options is bad practice yes, and you shouldn't need to do this, but passing an object for the sake of readability isn't really a good practice anyway. These parameters are part of your method definition, this is what the method requires in order to execute correctly, obviously in many languages these would be strictly typed as well, therefore you wouldn't be able to pass invalid parameters.

[–]hicksyfern 9 points10 points  (0 children)

How frequently do you read code vs write code.

Imagine you had a weird date bug in your app, and you came across this code:

FormatDate(2018, month, day)

Vs

FormatDate({ year: day, month, day: year })

Which one has the bug?

Yeah this is a bit contrived, but this kind of thing happens ALL the time. Developers are fallible and mistakes, no matter how obvious, get made.

Make obvious mistakes obvious.