From: James Britt Date: 2006-04-06T08:20:57+09:00 Subject: Re: best practices ara.t.howard@noaa.gov wrote: ... > > > sometimes i warp a bunch of lines into one, but in production code i > tend to > do this: > > duration = mins.to_i * 60 + secs.to_i > song = Song.new title, name > songs.append song > > otherwise it can be difficult to interpret stack traces with line numbers. > consider > > songs.append(Song.new(title, name, duration)) > > this can throw in Song.new or append - but both are on the same line. > using a > duration tmp var is also very self doccumenting. Good points, and very much what I tend to do. Over time, if I get tired at looking that the same chunk of known-good code, I may roll stuff up into tersitude, but that's mainly to make it easier to focus my eyeballs on something else. Stupid obvious works *real* well for me, so unless there is a significant cost to creating needless intermediary objects, I'd rather the code be explicit. Makes errors easier to pinpoint, and makes it more likely Mr. Britt will be able to work with is own code in the future. A little more typing today can mean a little less thinking later on. -- James Britt "In physics the truth is rarely perfectly clear, and that is certainly universally the case in human affairs. Hence, what is not surrounded by uncertainty cannot be the truth." - R. Feynman