3 ms·
Yes, don't use Magic Numbers, but use named constants instead. http://catb.org/jargon/html/M/magic-number.html http://catb.org/jargon/html/M/magic-number.html
by Karellen 5y ago
Yes, don't use Magic Numbers, but use named constants instead.
http://catb.org/jargon/html/M/magic-number.html http://catb.org/jargon/html/M/magic-number.html
https://en.wikipedia.org/wiki/Magic_number_(programming) https://en.wikipedia.org/wiki/Magic_number_(programming)
delay_ms = 300;
[...]
Thread.sleep(delay_ms);
Works in any programming language.
- Someone 5y agoFails in any programming language, too. delay_seconds = 300; [...] Thread.sleep(delay_seconds); This kind of bug can easily surface if you need the constant for calls taking different units and can be hard to spot.
- gpderetta 5y agoYes; still parent solution is better than nothing if you have to deal with an existing API. At least if you make a mistake there is a chance someone else might spot it instead of wondering what the original intent was.