3 ms·
You have to read the documentation. But you need to do that in order to be able to use the API properly anyway. The point the article is making is not about ma
by Karellen 5y ago
You have to read the documentation. But you need to do that in order to be able to use the API properly anyway.
The point the article is making is not about making it easier to write a line of code, but about making it easier to read a line of code. Given that most lines of code are read many more times than they are written, this is a good thing to focus on.
"Programs must be written for people to read, and only incidentally for machines to execute."
― Abel and Sussman, Structure and Interpretation of Computer Programs, 1984
- josephg 5y agoBeing forced to read the documentation carefully every time you call the method is really bad UX though. And the approach in the article (let ms = 5; sleep(ms);) can be wrong. Maybe the method is actually taking microseconds not milliseconds and this causes a bug. I can also imagine linters (or other humans) fighting this style, since it’s longer, and something you have to actively do every time you call the method. Putting the units in the method name (when you can) fixes all of this. Sleep_milliseconds(5) is impossible to misuse or leave undocumented.