Saturday, November 24, 2007

Agile test driven development or Software factory

An interesting article here looks at two different approaches to software development and testing: Agile/Extreme Programming and the Software Factory.

"The Agile camp argues that coding is good, and that the key to quality and productivity is extensive testing. One cornerstone of the Agile world is Test Driven Development: the idea that you should write your test code, then write the code to be tested. Code you don't write is always suspect, because it's difficult or impossible to test.

The Software Factory camp argues that generating code is good, and that the overall quality of generated code is higher than the quality of handcrafted code. The less code you write, the higher the quality of your application and the higher your productivity. Rather than writing code by hand, you are better off writing code to generate your code.

The idea of software generating software isn't new. It was tried extensively 15-20 years ago with an idea called Computer Aided Software Engineering (CASE). CASE tools allowed a developer to design and build their applications using high-level metaphors, often diagrams. If you look back at many of those tools, they don't look much different from the Domain Specific Language designers favored by the Software Factory advocates today. So you've got to wonder why Software Factories are going to succeed, when CASE ultimately failed.

Where things get strange is when teams try to mix Agile and Factory concepts. I've seen projects where most business code is generated, and then they also generate a bunch of tests for that generated code. Since both the code and tests come from the same meta-data and are generated by the same generator, it isn't surprising that the tests always work. This is typically done to satisfy some arbitrary requirement to achieve 90% code coverage with tests, but I question the value of tests that are generated automatically alongside the code they are testing.

So who is right? Should you stop using code-generation and handcraft both tests and all your code? Should you abandon the use of frameworks and pre-built components to ensure you can test all the code you use?"

Well you'll just have to go and read the article to find the conclusion the author draws!

Agile testing