Bindings, Platforms, and Innovation
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
Tracking change and innovation in the enterprise software development community
Posted by Mark Levison on Jan 28, 2008 05:40 AM
With the presence of high quality test generation tools like Agitar One and Parasoft's JTest, some are questioning the need to write tests manually. Uncle Bob (Martin) weighted in, exploring the weakness of the idea.
These tools are designed to examine an existing body of code. Based on branches, loops etc. they synthesize a set of observations about the code. The developer reviews the observations and chooses the relevant ones to create a set of test cases. In exploring legacy code this can be a very powerful way of understanding the existing behavior and creating a safety net before making changes.
However like any technology there are limits: these tools are only generating a set of observations about the code. They don't understand algorithms or the developer's intent. From Bob:
As a simple example of this, I have tried to generate tests for the bowling game program using two of the better known test generation tools. The interface to the Bowling Game looks like this:
public class BowlingGame {The idea is that you call roll each time the balls gets rolled, and you call score at the end of the game to get the score for that game.
public void roll(int pins) {...}
public int score() {...}
}The test generators could not randomly generate valid games. It's not hard to see why. A valid game is a sequence of between 12 and 21 rolls, all of which must be integers between 0 and 10. What's more, within a given frame, the sum of rolls cannot exceed 10. These constraints are just too tight for a random generator to achieve within the current age of the universe.
On the other hand, Test Driven Development (TDD), the process of writing the tests before writing the production code, works very differently. TDD works because it provides immediate feedback about the code the developer writes. Make a small change, run the test and the developer knows if the change was good. TDD ensures that the code matches our stated intentions (the tests). TDD makes us think about the design of the code from the point of view the consumer and not just the author. It makes us think about every conditional and loop. Additionally, as James Carr mentions, TDD forces us to consider how tightly coupled our code is. From Bob again:
Using a test generator breaks this concept because the generator writes the test using the production code as input. The generated test is not a human restatement, it is an automatic translation. The human states intent only once, and therefore does not gain insights from restatement, nor does the generated test check that the intent of the code was achieved. It is true that the human must verify the observations, but compared to TDD that is a far more passive action, providing far less insight into defects, design and intent.
... This does not mean that test generators aren't useful. ... I think they can help to partially characterize a large base of legacy code.
Effective Management of Static Analysis Vulnerabilities and Defects
Ebook: Scaling Agile with C/ALM
Ensuring Code Quality in Multi-threaded Applications
On JUnit factory they are very honest about what their tool generates: Characterization Tests. Artima had a pretty good series of articles about them. There really is no way for the test to generate code for the given example of a bowling game... Because the game logic/rules haven't been encoded as code. So there's no validation as to what is a valid game or not. That might say more about a failing of the code example than the test generators. TDD and Agile tend to say the code is the documentation; but if you're not expressing rules and validations in the code, where is it expressed? And how can any tool take advantage of it?
I agree Agitar is entirely honest, I don't know Parasoft well enough to comment. Their CTO Alberto Savoia has made statements on several occasions that Agitar's tools don't replace TDD. You're also right that the tool can't encode the rules because it hasn't been explicitly encoded in the Bowling Game. BTW I've not seen Bob's bowling code so that's only an assumption on my part. However even if the test generator did a perfect job of understanding the rules of bowling I still don't think it would capture the essence of TDD: - forces us to write small decoupled chunks of code - forces us to simplify - causes to consider the code from the context of its user as well as the code itself. By definition Test Generators miss this benefit because they come into play after you've written the code. I think that Agitar's tool is very useful but it doesn't replace TDD. I will try to get Alberto's attention to comment on this story.
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.
This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.
This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.
This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.
After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.
IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.
Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.
2 comments
Watch Thread Reply