Archive for December, 2008

Design and Testability, Which Comes First?

Jeremy Miller recently posted a good entry on Design and Testability. He talks about how important a good understanding of fundamental design principals is to writing testable code. I totally agree with this. I also believe that testing code is a great way to truly understand the benefits of applying design principals. Can you spot the circular dependency? 🙂

I first learned about the S.O.L.I.D. design principals several years ago and thought I was applying them in my code. However, it wasn’t until I started writing unit tests that I truly grasped the problems dependencies in particular can create in a system.

I eventually learned the hard way. In my early unit-tested applications, the tests ran slowly, often hit the database and required a fair amount of set up. The tests were still very beneficial, but the tight-coupling meant that it was difficult to refactor without breaking hundreds of tests.

So here’s the catch-22:

Without unit testing, you are unlikely the fully appreciate the effect dependencies have on a system.

But, without an understanding of good design principals, your unit tests may be ineffective, difficult to write, require a lot of set up and can quickly become hard to maintain. At which point you are likely to blame unit testing itself and not your lack of understanding the fundamentals of good design.

So what should come first? Learning about unit testing, thus feeling the pain of a poor design. Or, learning about good design but not fully understanding the benefits it has on a well structured and tested application?


Adventures In Ruby

I’ve recently been learning a bit about the Ruby programming language. What really struck a chord with me was watching Dave Thomas’ series of screencasts. These provide an excellent introduction to object-oriented programming in Ruby. There is a small fee per episode, but if you’re interested in a good introduction to Ruby, then I’d highly recommend trying at least the first three episodes.

I’m really excited about what Ruby can offer in terms of dynamic functionality. It’s a bit of a mind-shift coming from the more class-oriented perspective of C# and Java, into a truly dynamic object-oriented environment. But it’s this dynamism that let you be more expressive without being constrained by existing classes, or the type system of the language.

I have yet to look into Iron Ruby, which is the upcoming implementation of Ruby in .NET. But it’s exciting to think that we can use features of .NET with the expressiveness of Ruby.

For more information, check out this Alt.NET podcast.

And of course Dave Thomas’ screencasts mentioned above!