From: chiaro scuro Date: 2006-04-06T06:27:23+09:00 Subject: Re: best practices I like this multi-line nested format, that I call stanza (you know, like in poetry) songs.append Song.new( title, name, duration = ( mins.to_i * 60 + secs.to_i ) ) It clearly shows you what you are appending as a chunk of code on the right. the 'duration =' idiom makes the intent explicit. I use brackets to nest conceptual entities (Song, duration), so that they stand out as visually striking. Sometimes, using metaprogramming I also get rid of the explicit new by wrapping up object instantiation with a Song(..) method on the top level. I use this Implicit Constructor because I don't want to be concerned with object creation in my code, just with the meaning of the entities that I am manipulating. songs.append Song( title, name, duration = ( mins.to_i * 60 + secs.to_i ) ) -- Chiaroscuro --- Liquid Development: http://liquiddevelopment.blogspot.com/ On 4/5/06, Keith Sader wrote: > IMO your second version is better since the intent is clear. IMO, > make the intent clear at the expense of concision. > > However, do what works best for you and your team. > > On 4/5/06, 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?