On May 6, 2011, at 11:25 AM, gw wrote:
> I see this as good an opportunity as any to discuss variable names
> (sorry if this turns into a hijacking of the thread, but maybe the
> feedback will tell Eitan whether this is an important detail for him
> to consider).
>
> Personally, I cringe when I see cryptic variables like:
>
> u.login and u.reset_token # in business_users.rb
> u = Admin.authenticate(...) # in admins.rb
> bus_user = valid_bus_user_token?(...) # in app_subscriptions.rb
I didn’t look at the original. But I thought it worth mentioning that my
philosophy is that variable name verbosity should be proportional to variable
scope size. So, for example, this is fine:
Users.where(…some condition…).map{|u| …do something with u…}
because you’re only using u on that one line, so don’t make the line longer by
making me read user_who_has_a_gammy_left_leg.
But if you’re using a variable over more than say two or three lines, its name
should be descriptive.
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby