Hacker News new | ask | show | jobs
by lugged 1693 days ago
Use the right tool for the job. You can use both and it doesn't make the code any more or less readable. Using one only certainly does limit your abilities to write clean code and in the case of this pattern encourages some nasty shit.

Parameter count denotes logical branches like an if statement.

If you're passing in more than two to three Params a parameter object quickly becomes desireable.

Forcing parameter objects for one or two parameter functions seems.. stupid to say the least.

Boolean parameters are extremely rare if you're code is clean. They're essentially a code smell that indicate someone has dropped a hack in the middle of your function and handed in a parameter to toggle the behavior on in their one case against all others.

You're much better off writing a new function that triggers the new behavior and wraps a call to the old one.

Similar story for object returns, if you need to return an object that's fine but to be honest destructuring an object straight away makes code pretty hard to read in a lot of cases (not all).

For returning two parameters I'm pretty confused about the code, it's likely breaking single responsibility and signalling sideeffects.