News for hackers. Stuff that matters.
Re:Sizeof(char) is 1 by tetha on Monday September 06, 2010 @07:12AM (#1666434)
I'd go even further with the issue. These constants do not offer _any_ abstraction or readability, and precisely this is the issue.

Naturally, I like constants like POPCORN_PRICE = 12 or whatever. They add meaning to meaningless numbers.

I am on the fence for HOUR_PER_DAY and MINUTE_PER_HOUR, because they never change, but they at least add a certain security if you chain them together. bar = lengthInSeconds * SECONDS_IN_MINUTE * MINUTES_IN_HOUR * DAYS_IN_YEAR. In this case you can simply match. Seconds - Seconds, fits. Minute - Minutes, fits. Hour - days... wait, doesn't fit.

However, if you look at PROTOCOL + COLON + SLASH + SLASH versus "http://, there is just nothing added.

Re:Sizeof(char) is 1 by masklinn on Monday September 06, 2010 @07:26AM (#1666448)
> I am on the fence for HOUR_PER_DAY and MINUTE_PER_HOUR, because they never change, but they at least add a certain security if you chain them together. bar = lengthInSeconds * SECONDS_IN_MINUTE * MINUTES_IN_HOUR * DAYS_IN_YEAR.

Ideally, especially if you're using a strongly typed language, you should just use time-unit types (or at least macros or inlinable functions) for that: `fromSeconds(lengthInSeconds).toYears()`, lengthInSeconds.seconds.to_year, `SECONDS_TO_YEARS(lengthInSeconds)`, new TimeSpan(seconds=lengthInSeconds).toYears(), etc...)