Show, Don’t Tell

by Krishna on October 10, 2009

The title comes from the field of literature and art where writers (and movie directors) are rebuked for using narration (“he was sad”) instead of using actions and thoughts of a character to illustrate a situation.

Much of the recent debate over unit tests and Inversion of Control has been the meta discussion: “Unit tests are hard” versus “No, they are not” and so on. Which is why Rob Conery’s post on IoC and its sequel are worth reading. Well, at least for the .NET audience. Honorable mention also goes to Justin Etheredge for a similar (but less detailed) article.

I would note a few points. First is that not all IDEs and IoC containers are created equal. Those who are working outside the .NET space and are not using commercial products can sometimes find the going tough. Maybe this is just my experience with open source tools, but it does take a non-trivial amount of time to set up your environment properly and then work with it easily.

This should not deter someone who wants to get it done. But if someone is exploring how it is working, there is a barrier for such beginners and can sour them on the experience. My advice to the open source community is to come up with installation packages that can make it easy for such programmers to get started with these tools easily. Greater usability will mean proliferation of best practices in the general programming community.

Second, there is a virtuous cycle in place with these programming practices. Someone using TDD has a greater chance of using IoC. And that same person is more likely to learn and use design patterns where applicable. So you perhaps only have to give a small push to a programmer to get them rolling on the way to adopt these best practices. Start them with unit tests and soon they will be on to bigger things.

Finally, while we have good tools, there is still scope for improvement. A common complaint about TDD are tests that achieve greater coverage, but are either meaningless or boiler-plate stuff. There can be more intelligent unit testing tools that generate generic tests, allow the programmer to override them where necessary and spend more time on writing tests for more complex code. We are getting there, especially in the .NET space, but more of that would be better.

Comments on this entry are closed.

Previous post:

Next post: