From: Jean-Charles Carelli Date: 2006-04-07T03:48:18+09:00 Subject: Re: best practices Many thanks for the feedback. The general consensus is: Keep it readable ! I chose to learn Ruby for many reasons. Two big reasons were: the Pragmatic guys like Ruby, and Martin Fowler likes Ruby. So, as I work through the Pick Axe book, I feel like the code samples don't follow in the tradition of what Martin Fowler or the Pragmatic guys would recommend. This is not an attack of the Pick Axe book. It's great, and I'm learning things quickly. My main concern was that I was learning a language that appeared to be written in as cryptic a manner as possible. Yes, I know I can do as I like. But just as two space indents are recommended, I want to write code other Ruby developers will feel comfortable with. So, I'll refactor, break things up, and I will not be afraid to be verbose. Cheers! J-C On Apr 6, 2006, at 11:58 AM, Pistos Christou wrote: > Jean-Charles Carelli: I always go for a little more verbosity rather > than sacrifice clarity or readability in an attempt to compress code > into the most terse articulation. I use whitespace and > my-typing-speed-is-fast-enough-to-type-long variable names, and > break up > long lines with newlines and indentation (as per Chiaro Scuro's > examples). > > Jeff Cohen wrote: >> def append_song(title, name, mins, secs) >> duration = mins.to_i * 60 + secs.to_i >> song = Song.new title, name >> songs.append song >> end >> >> so then the original line way above becomes >> >> append_song title, name, mins, secs > > This sort of throws up a warning flag for me. :) Code like that > makes > it feel like PHP's > becauseweshyawayfrom_objectsandnamespaces_inthisdomain_wewilldothis_wi > ththesethings( > args... ), and moves away from myobject.mymethod.myothermethod > ( args... > ). > > I would still keep songs.append song (or songs << song). > > Pistos > > -- > Posted via http://www.ruby-forum.com/. >