Chapter 3. TDD and Refactoring


A good example is a powerful thing; I think we are in agreement on that. One way to describe Test-Driven Development (TDD) is to say that you use tests or examples for specifying the behavior. Those examples will serve you over and over again for many different purposes. They will serve you during development, for example, for finding lacking or incorrect requirements. When you refactor, the tests will be a safety net. After development they will serve you as quality documentation.

In this chapter we will not just talk about tests as examples; we will discuss TDD itself with some examples. I just think that's a good way of describing what it's all about.

After some initial discussion of TDD and the state-based style, my friend Claudio Perrone will discuss some techniques for creating examples the interaction-based way, writing tests by using stubs and mocks.

A key principle that is used during TDD is refactoring. Even refactoring is pretty example-centric. You can think of it as writing a first example of a piece of the solution, then using refactoring to refine that example until you're done. So you don't have to come up with a perfect design up front. That is good news, because it is close to impossible anyway.

Again, we will discuss refactoring with some examples, of course.

Let's start with some basics about TDD.




Applying Domain-Driven Design and Patterns(c) With Examples in C# and  .NET
Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
ISBN: 0321268202
EAN: 2147483647
Year: 2006
Pages: 179
Authors: Jimmy Nilsson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net