Remix.run Logo
paulddraper 3 hours ago

This article relates to two classic principles:

1. Avoid long parameter lists [1]

2. Avoid boolean arguments [2]

For #1, long parameter lists should be named (named arguments, options object, etc).

For #2, and booleans should be replaced by meaningful enumerations.

> toggleMenu(true); That’s clear enough. the meaning is obvious

Actually, it's incredible ambiguous. Is that toggling the menu? Or setting it to the open state? Or something else? I have no idea.

  setMenuState(MenuState.OPEN)
  setMenuState(MenuState.CLOSED)
[1] https://testing.googleblog.com/2024/05/avoid-long-parameter-...

[2] https://alexkondov.com/should-you-pass-boolean-to-functions/

benj111 an hour ago | parent [-]

I was thinking the same.

ToggleMenu(); should do it. Or is there something I'm missing? Ie is the function misnamed? OpenMenu(true); maybe what the function is doing?