Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not take boolean as function param #28

Closed
Ilanaya opened this issue Mar 25, 2024 · 1 comment
Closed

Do not take boolean as function param #28

Ilanaya opened this issue Mar 25, 2024 · 1 comment

Comments

@Ilanaya
Copy link
Contributor

Ilanaya commented Mar 25, 2024

When you are reading this code can you quickly tell what false and true as argument stand for?

orderedWeekDays.forEach(day => {
addButtonAction(bot, `btn${day}`, getLessonsForDay(day, dataBase, false))
addButtonAction(bot, `btn${day}NextWeek`, getLessonsForDay(day, dataBase, true))

Basically, booleans in the function params should be avoided and replaced with options object, i.e. check the difference between calls

makeRequest('/api/data' , true)

makeRequest('/api/data' , { raw: true }

The second call looks much more readable.

I suggest:
Find all boolean params in code and replace them with options object

@Ilanaya
Copy link
Contributor Author

Ilanaya commented Mar 25, 2024

Btw, in some low level or performance dependent api's it is normal to sacrifice some readability.
Check this comment in the vue core repo for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant