From: Ryan Davis Date: 2010-12-23T13:40:10+09:00 Subject: Re: How to DRY code to prompt for parameters On Dec 22, 2010, at 20:10 , RichardOnRails wrote: > I pasted code to prompt for a couple of parameter-values at > http://www.pastie.org/1399710. > > Running this code under SciTE produces, for example: > Getting parms > Account Number: 123 > Report Period: 456 > Showing parms > @acct_num = 123 > @acct_period = 456 > > It is excessively verbose because I couldn't figure out how to use > meta-language to specify the parameter target names. It is excessively verbose because you wrote 53 lines when 4 would do: print "Account Number: " @acct_num = gets.to_i print "Report Period: " @acct_period = gets.to_i There is nothing wrong with that code. It doesn't have to be 13x more complex to ask the user 2 simple questions. The definition of DRY is "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system" not "ZOMG I see a 2 line pattern! must kill!" Please. Do the simplest thing that could possibly work. P.S. AGAIN with the tabs. I almost didn't write this email at all just because reading your code is too hard.