5 ms·
I can understand the reasoning, in this specific case. But having every function designating their unit is a new hungarian notation. Imagine working with: setS
by yummybear 5y ago
I can understand the reasoning, in this specific case. But having every function designating their unit is a new hungarian notation. Imagine working with:
setSpeedInKilometersPerSecond vs. setSpeed
I'd rather have it baked into the language ala CSS ("100ms").
- kuu 5y agoDo they charge you by written bytes? I really don't see the problem with larger function names...
- OskarS 5y ago"It's annoying" is a pretty good reason. If you don't mind function names like that, go become a Java Enterprise programmer, see how you like it after a few years. In addition: it's the wrong solution to the problem. The units shouldn't be baked in to the function definition, just the type of quantity. You should be able to do both: setSpeed(10 m/s) and setSpeed(45 km/h) Which you can do in many languages. In fact, time functions in C++ work exactly like this. If you want to suspend a thread for 10 seconds you do std::this_thread::sleep_for(10s); but if you want to suspend it for 5 milliseconds, you do std::this_thread::sleep_for(5ms); And if you just supply a unitless number, it's a compiler error.
- deleted 5y ago[deleted]
- tirpen 5y agoAre you coding without any form of auto completion?
- qayxc 5y agoAs silly as this may sound, you may run into issues with certain linters or formatting tools in some languages. A prominent example is PEP8 in Python, which suggests a line length limit of 79 characters (though 80-100 chars are considered to be "OK" as well). Long variable or function names can lead to distracting "forced" line breaks in such scenarios.
- yummybear 5y agoIs anyone these days? That said I, personally, do prefer more concise naming.
- ParetoOptimal 5y agoIMO it's about readability, not the typing that can be automated.
- berkes 5y agoFirst, I'd say that you probably want to invest in your IDE or editor. But more important: there's middleground. What about setSpeedMmps() if setSpeedInMillimeterPerSecond is too noisy. My ROT is that the unit or type designation schould not overshout the most important info. Which, in case of setSpeedInMillimeterPerSecond is arguably, indeed the case. But the solution is almost never binary, but a more succint version. Everyone understands km, mm, sec, hr (though the win with such is silly) px and so on.
- ParetoOptimal 5y ago> What about setSpeedMmps Mmps would be confusing and frustrating the first time I think.
- Mazzen 5y agoYou are missing one crucial element here: `setSpeed(meterPerSecond: float)`