Unit Tests Are the Answer for Duck Typing

Today in discussion about Static vs. Dynamic typing, Mike Moore (who runs the Boise Ruby on Rails group), posted a link to a blog post by Bob Martin where the case is made for using unit tests to catch any possible typing errors. I really liked this quote: “I tried writing some applications in Python, and then Ruby (well known dynamically typed languages). I was not entirely surprised when I found that type issues simply never arose. My unit tests kept my code on the straight and narrow. I simply didn’t need the static type checking that I had depended upon for so many years.”This makes sense. We know that ColdFusion is a dynamically typed language (as I think it should be), but if you throw static types out the window, you could run into data corruption problems. However, if you build solid unit tests, that shouldn’t be a problem. The unit tests will catch any data problems you might run into.