The next programmer doesn't need to see those digits at all, they're nothing but a distraction.
The next programmer doesn't need to see those digits at all, they're nothing but a distraction.
newTime = currentMillis + 21600000,
I go WTF is that number and is it right,
newTime = currentMillis + SIX_HOURS_IN_MILLIS
and I not only know at a glance what you're doing, I know what the value ought to be, so if you accidentally added/left out a zero, I can actually check it where that const is declared.
newTime = currentMillis + 6 * HOUR_IN_MILLIS
But an even cleaner solution would be to just use the date/time library for this (depending on the language, of course): newTime = currentMillis + TimeSpan.FromHours(6).Milliseconds;More importantly: Why 6 hours?
The comment by bluefinity gets it right. HOURS_IN_MILLISECONDS is ok, but don't "constant" everything.
newTime := currentMillis + 6 hours asMilliseconds.
That's been my experience. I've yet to work on or with a team that has been able to resolve the concept of a consistent coding standard.
Yes, so if it's only one case you can have the comment
Now, if you're doing it a lot of times I bet your problem is bigger than just adding a constant, it may be even better to turn this into a function so you do to_seconds(time_in_hours) or something