4 ms·
> sometimes do > rarely do Are terrible for maintainability. Imagine that you are reading through the code of a programmer who used this library - What is 'so
by jrogers65 14y ago
> sometimes do
> rarely do
Are terrible for maintainability. Imagine that you are reading through the code of a programmer who used this library - What is 'sometimes'? What is 'rarely'? It would need to be documented on each usage to save half an hour of digging and cursing for the poor sap who encounters it.
> 1.percent_of_the_time do
For the same reasons, this would be better named "times_out_of_one_hundred" since The Time usually means a time of some sort being somewhere (i.e. the 21:43:21 type of time).
At least you foresaw some peoples' reactions to this:
https://github.com/sudara/sometimes/blob/master/test/helper.rb https://github.com/sudara/sometimes/blob/master/test/helper....
- sudara 14y agoAgreed with all of that! Especially the poor sap who is reading the code wondering WTF... So — my thinking for those two methods is to purposefully encourage being imprecise. We are always so obsessed with being exact in programming. And typically for good reasons. But in some cases, perhaps it doesn't matter if it's 50% of the time or 20% or 10% of the time. Just sometimes, not all of the time. That being said, you bring up a fantastic point: what the hell does 'sometimes' mean? Half the time? What does rarely mean? It's certainly going to depend on the individual. No answers here, except I'm leaning towards redefining "sometimes" to mean between 15-50% of the time.
- patio11 14y agoGoogling for ["sometimes do" ruby] returns this library as the 2nd result.