4 ms·
"Let's just throw away the single responsibility principle and give Integer a method that multiplies it by the number of seconds in a day, and another one that
by philwelch 13y ago
"Let's just throw away the single responsibility principle and give Integer a method that multiplies it by the number of seconds in a day, and another one that adds it to the current day to get a new Time or Date object. Obviously that's something that an integer should be concerned with."
- matthewmacleod 13y agoThat's kind of the philosophy of Ruby though, and ActiveSupport by extension. Where it makes code clearer and more concise, or where it simplifies an often-used idiom, and where it outweighs the benefit of sticking to principles—as I believe it does here—then breaking those principles is acceptable, in languages where coding conventions support this.
- philwelch 13y agoI don't think `2.days.ago` makes code any clearer or appreciably more concise than, for instance, `Date.today - Date.days(2)` (or even, to meet you in the middle, `Date.today - 2.days`).
- steveklabnik 13y agohttps://news.ycombinator.com/item?id=6976450 https://news.ycombinator.com/item?id=6976450
- jshen 13y agoWe must not mistake principles and guidelines for absolute rules. I'm not judging this particular case, but I see the SOLID guidelines treated as absolutes far too often.