From: CHubas Date: 2007-02-23T11:20:05+09:00 Subject: Re: Trade-off between variable name descriptiveness and readability On Feb 22, 4:58 am, "David Vallner" wrote: > On Thu, 22 Feb 2007 06:32:26 +0100, Daniel Finnie > > > > wrote: > > > def sing_song(start) > > > start.downto(1) do |num| > > Quoth Mr. Torvalds: 'If you have some random integer loop counter, it > should probably be called "i". Calling it "loop_counter" is > non-productive, if there is no chance of it being mis-understood.' > > I'd go with that, and not putting a #bottles method into Integer - I find > that more or less pointless. > David Vallner For actual classes, I should agree, but to teach a newbie, I'd go with num.bottles or num_bottles, as they're more explanative to keep track of where did they come from, and what should they do. Also, the implementation of the method depends on what are you pretending to show (assuming it's for teaching). If you want to show the power of OO, I'd stick a #bottles method onto Fixnum; if you want to show blocks, I'd go with a method that yields the number of bottles (or the string "No more"); I think in this case, you should give more than one option. For example, another way would be. class Wall attr_accessor :bottles def initialize(bottles) @bottles = bottles end def to_s "the wall" end def sing "#{@bottles} of beer on #{self} ..... etc... and analyze which solution is the best. A good exercise for your traine� wold be select the best approach and state why it is so. Just sharing my point of view. Ruben.