I'd argue that in the example given (formatting numbers with precision for display), using constants like:
float_as_thousands_with_precision(amps, PRECISION_OF_AMPS) instead of just: float_as_thousands_with_precision(amps, 2) is probably overkill, since it's presentation code. I agree that there is an argument in favor of using a constant (if you anticipate that you may need to change the precision on several items later, for instance), but let's say you're putting this in a view template. Where would you define the constant? In the view? In the controller? In an initializer? Sometimes it's more of a pain to have to figure out where the constant is defined and look it up, instead of just seeing the number right there. Jarin On Saturday, April 21, 2012 10:24:07 AM UTC-7, greg willits wrote: > > Anyone in a theoretical mood today? I have a team debate going on re: > Magic Numbers, more specifically a case where literals are not magic, > and never will be magic. > > I posted the story here http://www.ruby-forum.com/topic/4100627. > Robert Klemme piped up (good enough for me), but a bigger sample of > opinions would be better. > > It's a trivial detail, but hey what's the point of good coding > practice if you aren't going to hash out semantics over the details I > figure. > > If'n yer in the mood, all opinions welcome. Thanks. > > -- greg willits > > -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
