From: John Carter Date: 2006-04-07T06:16:59+09:00 Subject: Re: best practices I can take and I also do either. I tend to wrap around 70 characters. That probably is because I learnt to program with punch cards, :-) but may be because it actually is more readable. One hard and fast rule. NEVER BURY SIDEEFFECT EXPRESSIONS DEEP IN AN EXPRESSION. For example... If you had... songs.append(Song.new(title.gsub!(/_/, ' '), name, mins.to_i * 60 + secs.to_i)) I would ALWAYS refactor that to... title.gsub!(/_/, ' ') songs.append(Song.new(title, name, mins.to_i * 60 + secs.to_i)) On Thu, 6 Apr 2006, Jean-Charles Carelli wrote: > I'm working my way through the Pickaxe book and I have a question regarding > syntax and best practices. > > Example from page 64 > > # 1 Book example > songs.append(Song.new(title, name, mins.to_i * 60 + secs.to_i)) > > > # 2 Alternate version. > duration = mins.to_i * 60 + secs.to_i > songs.append(Song.new(title, name, duration)) > > > Version 1 is very concise but harder to read. Ruby is very intuitive but I > find the second example easier to read. What is everyone else doing? > > J-C > > John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand Carter's Clarification of Murphy's Law. "Things only ever go right so that they may go more spectacularly wrong later." From this principle, all of life and physics may be deduced.