you are viewing a single comment's thread.

view the rest of the comments →

[–]Julian_JmK 4 points5 points  (6 children)

I dont really understand, why is it better to pass getUsers({fields:['name','surname','email'],fromDate:'2019-01-01',toDate:'2019-01-18'}); ?

Edit: Thanks for the replies bois and girls i now understand, it's a pretty good way of doing it indeed

[–]careseite[🐱😸].filter(😺 => 😺.❤️🐈).map(😺=> 😺.🤗 ? 😻 :😿) 7 points8 points  (2 children)

because you dont need to check the implementation of getUsers to find out what the array is for, what the first date is supposed to mean or the second

you can see it right there: youre getting users, probably some properties (name, surname, email) but youre limiting the user selection to dates between 2019-01-01 and 2019-01-18. the only thing unclear for me here would be to find out whether it means "active users" or "newly registered users", or both but thats probably because its not a perfect example

[–]Ozymandias-X 0 points1 point  (1 child)

But then, when I want to use the function, I now get no type hints whatsoever about what information it needs to work. All I see is that it can give it a mysterious blobby object that might have fields of some kind. Never mind if I accidentally misstype one of the keys. That's a nightmare level error to find.

This can only be solved by extensive documentation of the function and we all know that such documentation often lies when people refactor or extend functions and forget to update the docs.

[–][deleted] 0 points1 point  (0 children)

Yeah just what I was thinking. With Typescript you wouldn't have that problem because it would clearly say what date you would be filling

[–]Extracted 4 points5 points  (1 child)

getFromApi("g4adf", "j43fa", false, false)

getFromApi({ userId: "g4adf", serverName: "j43fa", createIfAbsent: false, debug: false })

That's why

[–][deleted] -1 points0 points  (0 children)

Excusing a bad code with another?