From: Jay Levitt Date: 2007-12-10T09:55:00+09:00 Subject: Re: How much would variable declarations in Ruby make you wince? On Sun, 09 Dec 2007 00:51:17 GMT, Just Another Victim of the Ambient Morality wrote: > The two most popular sources of bugs for me when programming in Ruby > are: > > 1) Passing the wrong object as a parameter to a method. > 2) Accidentally creating a new variable. > > Unfortunately for me, very little can be done about my first point. I > understand and enjoy the power of duck-typing, which specifically allows me > to exercise this bug. > However, something can be done about the second point. Let me exemplify > the problem: I suspect that both #1 and #2 are because you're not doing TDD/BDD. When I first came to Ruby from statically-typed languages, I had exactly the same problem, for exactly that reason. I *constantly* made typos. Then I started playing with RSpec, and writing all my specs first, and - magically - all those types of bugs disappeared (or, rather, were caught the minute I clicked "save", thanks to ZenTest's autotest). The proof, to me, was that I've recently been on a contract that took me back to PL/I - one of the more restrictive statically-typed languages. Wouldn't you know it: Nearly every time I tried to compile, I found at least one mistyped variable name. Go figure. -- Jay Levitt | Boston, MA | My character doesn't like it when they Faster: jay at jay dot fm | cry or shout or hit. http://www.jay.fm | - Kristoffer