Re:Rust is surprisingly expressive
by philwelch on Saturday December 28, 2013 @05:25PM
(#6976928)
"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."
[ Parent
| on HN ]
Re:Rust is surprisingly expressive
by matthewmacleod on Saturday December 28, 2013 @05:38PM
(#6976977)
That'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.
I 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`).
We 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.
Re:Rust is surprisingly expressive
by steveklabnik on Saturday December 28, 2013 @05:45PM
(#6977007)