--0016367fb0cf91e713048793f8de Content-Type: text/plain; charset=ISO-8859-1 On Thu, May 27, 2010 at 8:05 AM, Martin Hansen <mail / maasha.dk> wrote: > Josh Cheek wrote: > > On Thu, May 27, 2010 at 7:26 AM, Martin Hansen <mail / maasha.dk> wrote: > > > >> > Hash, OpenStruct or custom class for transportation of your options. > >> Thanks, I am working hard on it! > >> Posted via http://www.ruby-forum.com/. > >> > >> > > If you have a comprehensive set of tests, then people can refactor > > without > > fear of breaking. > > I am working on comprehensive unit testing of class biopieces, but > "Biopiece writers" should not change anything in that class. They should > only concentrate on what is in the script they are writing and whatever > classes they write to expand that. > > > Martin > -- > Posted via http://www.ruby-forum.com/. > > I meant rubyists. For example, the time_diff method at the very end can probably be rewritten def time_diff(t0, t1) day0 , hour0 , min0 , sec0 0.split(/\D+/)[2..-1].map { |n| n.to_i } day1 , hour1 , min1 , sec1 1.split(/\D+/)[2..-1].map { |n| n.to_i } sec0 + ( day0 * 24 + hour0 ) * 60 + min0 ) * 60 sec1 + ( day1 * 24 + hour1 ) * 60 + min1 ) * 60 sec sec1-sec0 sprintf '%02d:%02d:%02d' , sec/60/60 , sec/60%60 , sec%60 end But I don't know for sure, without a bunch of tests to show it behaves the same way. I think the math at the end is probably right, but haven't had a math course in 2 years, would you rather trust correctness to my "probably right" or to your ironclad test suite? And when looking at it, I see we don't use year or month, so I wonder if it has bugs, and I'm just refactoring bugs, which makes it very difficult to get motivated. I might also be inclined to play with DateTime to see if it has this functionality within it, in which case the whole method could probably be replaced with 1 line, but its not immediately obvious to me if it does, so it would be nice to have some tests that I can know how close I am getting. --0016367fb0cf91e713048793f8de--