DELIVERY & GIFT DETAILS:
Usually ships within 24 hours
Delivery Time and Shipping Rates
Eligible for gift wrap & gift message.

Reserve it at BN.com & pick it up in 60 minutes at your local store.
Enter a zip code
(Paperback - New Edition)
Reader Rating: (5 ratings)
Detailed Rating: "Organization" See All
Presents an approach to writing software that emphasizes automated testing before and during coding. Written for advanced programmers, the book walks through two example projectsmulti-currency arithmetic and the xUnit testing frameworkand provides patterns for deciding what tests to write and how to write tests using xUnit. The code is written in Java and Python. Annotation c. Book News, Inc., Portland, OR
More Reviews and RecommendationsKent Beck consistently challenges software engineering dogma, promoting ideas like patterns, test-driven development, and Extreme Programming. Currently affiliated with Three Rivers Institute and Agitar Software, he is the author of many Addison-Wesley titles.
Reader Rating:
See Detailed Ratings
November 03, 2009: I found this book a valuable introduction to TDD
Reader Rating:
See Detailed Ratings
October 11, 2009: Test driven development (TDD) is a landmark development in the craft of software development, and Kent Beck is one of its inventors. This is a great book for software professionals wanting an introduction to techniques, with clean and straightforward examples of the fundamental concepts and the basic approach. This book is thinner than most of the other books in this field, which may be what you want if you are short on time or haven't yet decided on whether you want to start writing code this way. On the other hand, if you already have experience with xUnit and you are in the midst of testing a complex application, you may find this book somewhat short on the details involved in knowing the difference between good tests and merely adequate tests.
I Also Recommend: xUnit Test Patterns.
The Barnes & Noble Review
Every developer wants to write clean code that works -- but somehow, forces always seem to conspire to prevent that. Kent Beck has spent a career on the problem of improving software development: you probably know him best for inventing Extreme Programming (XP).
XP relies heavily on incremental testing. But this often slips up implementers, for whom constant testing represents a radical change. In Test-Driven Development, Beck brings testing to life, showing exactly how to use it to close the gap between decisions and feedback.
“TDD” has only two rules. No. 1: Write new code only if you first have a failing automated test. No. 2: Refactor constantly to eliminate duplication. But these rules have complex and subtle implications. You must “design organically,” making decisions based on whether your code passes its test. You must organize your development environment so this is possible. You must write your own tests: you can’t wait for specialists. And your designs must consist of highly cohesive, loosely coupled components: otherwise, micro-scale testing is simply impossible.
If this still sounds difficult at best, Beck demonstrates TDD through a book-length case study. Its “in-practice” workings will surprise you -- and, we think, convince you. Bill Camarda
Bill Camarda is a consultant, writer, and web/multimedia content developer. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.
Clean code that worksnow. This is the seeming contradiction that lies behind much of the pain of programming. Test-driven development replies to this contradiction with a paradoxtest the program before you write it.
A new idea? Not at all. Since the dawn of computing, programmers have been specifying the inputs and outputs before programming precisely. Test-driven development takes this age-old idea, mixes it with modern languages and programming environments, and cooks up a tasty stew guaranteed to satisfy your appetite for clean code that worksnow.
Developers face complex programming challenges every day, yet they are not always readily prepared to determine the best solution. More often than not, such difficult projects generate a great deal of stress and bad code. To garner the strength and courage needed to surmount seemingly Herculean tasks, programmers should look to test-driven development (TDD), a proven set of techniques that encourage simple designs and test suites that inspire confidence.
By driving development with automated tests and then eliminating duplication, any developer can write reliable, bug-free code no matter what its level of complexity. Moreover, TDD encourages programmers to learn quickly, communicate more clearly, and seek out constructive feedback.
Readers will learn to:
This book follows two TDD projects from start to finish, illustrating techniques programmers can use to easily and dramatically increase the quality of their work. The examples are followed by references to the featured TDD patterns and refactorings. With its emphasis on agile methods and fast development strategies, Test-Driven Development is sure to inspire readers to embrace these under-utilized but powerful techniques.
Loading...| Preface | ||
| Acknowledgments | ||
| Introduction | ||
| Pt. I | The Money Example | 1 |
| Ch. 1 | Multi-Currency Money | 3 |
| Ch. 2 | Degenerate Objects | 11 |
| Ch. 3 | Equality for All | 15 |
| Ch. 4 | Privacy | 19 |
| Ch. 5 | Franc-ly Speaking | 23 |
| Ch. 6 | Equality for All, Redux | 27 |
| Ch. 7 | Apples and Oranges | 33 |
| Ch. 8 | Makin' Objects | 35 |
| Ch. 9 | Times We're Livin' In | 39 |
| Ch. 10 | Interesting Times | 45 |
| Ch. 11 | The Root of All Evil | 51 |
| Ch. 12 | Addition, Finally | 55 |
| Ch. 13 | Make It | 61 |
| Ch. 14 | Change | 67 |
| Ch. 15 | Mixed Currencies | 73 |
| Ch. 16 | Abstraction, Finally | 77 |
| Ch. 17 | Money Retrospective | 81 |
| Pt. II | The xUnit Example | 89 |
| Ch. 18 | First Steps to xUnit | 91 |
| Ch. 19 | Set the Table | 97 |
| Ch. 20 | Cleaning Up After | 101 |
| Ch. 21 | Counting | 105 |
| Ch. 22 | Dealing with Failure | 109 |
| Ch. 23 | How Suite It Is | 113 |
| Ch. 24 | xUnit Retrospective | 119 |
| Pt. III | Patterns for Test-Driven Development | 121 |
| Ch. 25 | Test-Driven Development Patterns | 123 |
| Ch. 26 | Red Bar Patterns | 133 |
| Ch. 27 | Testing Patterns | 143 |
| Ch. 28 | Green Bar Patterns | 151 |
| Ch. 29 | xUnit Patterns | 157 |
| Ch. 30 | Design Patterns | 165 |
| Ch. 31 | Refactoring | 181 |
| Ch. 32 | Mastering TDD | 193 |
| App. I: Influence Diagrams | 207 | |
| App. II | Fibonacci | 211 |
| Afterword | 215 | |
| Index | 217 |
“Clean code that works” is Ron Jeffries’ pithy phrase. The goal is clean code that works, and for a whole bunch of reasons:
In Test-Driven Development, you:
Two simple rules, but they generate complex individual and group behavior. Some of the technical implications are:
The two rules imply an order to the tasks ofprogramming:
1. Red—write a little test that doesn’t work, perhaps doesn’t even compile at first
2. Green—make the test work quickly, committing whatever sins necessary in the process
3. Refactor—eliminate all the duplication created in just getting the test to work
Red/green/refactor. The TDD’s mantra.
Assuming for the moment that such a style is possible, it might be possible to dramatically reduce the defect density of code and make the subject of work crystal clear to all involved. If so, writing only code demanded by failing tests also has social implications:
So, the concept is simple, but what’s my motivation? Why would a programmer take on the additional work of writing automated tests? Why would a programmer work in tiny little steps when their mind is capable of great soaring swoops of design? Courage.
Test-driven development is a way of managing fear during programming. I don’t mean fear in a bad way, pow widdle prwogwammew needs a pacifiew, but fear in the legitimate, this-is-a-hard-problem-and-I-can’t-see-the-end-from-the-beginning sense. If pain is nature’s way of saying “Stop!”, fear is nature’s way of saying “Be careful.” Being careful is good, but fear has a host of other effects:
None of these effects are helpful when programming, especially when programming something hard. So, how can you face a difficult situation and:
Imagine programming as turning a crank to pull a bucket of water from a well. When the bucket is small, a free-spinning crank is fine. When the bucket is big and full of water, you’re going to get tired before the bucket is all the way up. You need a ratchet mechanism to enable you to rest between bouts of cranking. The heavier the bucket, the closer the teeth need to be on the ratchet.
The tests in test-driven development are the teeth of the ratchet. Once you get one test working, you know it is working, now and forever. You are one step closer to having everything working than you were when the test was broken. Now get the next one working, and the next, and the next. By analogy, the tougher the programming problem, the less ground should be covered by each test.
Readers of Extreme Programming Explained will notice a difference in tone between XP and TDD. TDD isn’t an absolute like Extreme Programming. XP says, “Here are things you must be able to do to be prepared to evolve further.” TDD is a little fuzzier. TDD is an awareness of the gap between decision and feedback during programming, and techniques to control that gap. “What if I do a paper design for a week, then test-drive the code? Is that TDD?” Sure, it’s TDD. You were aware of the gap between decision and feedback and you controlled the gap deliberately.
That said, most people who learn TDD find their programming practice changed for good. “Test Infected” is the phrase Erich Gamma coined to describe this shift. You might find yourself writing more tests earlier, and working in smaller steps than you ever dreamed would be sensible. On the other hand, some programmers learn TDD and go back to their earlier practices, reserving TDD for special occasions when ordinary programming isn’t making progress.
There are certainly programming tasks that can’t be driven solely by tests (or at least, not yet). Security software and concurrency, for example, are two topics where TDD is not sufficient to mechanically demonstrate that the goals of the software have been met. Security relies on essentially defect-free code, true, but also on human judgement about the methods used to secure the software. Subtle concurrency problems can’t be reliably duplicated by running the code.
Once you are finished reading this book, you should be ready to:
This book is organized into three sections.
I wrote the examples imagining a pair programming session. If you like looking at the map before wandering around, you may want to go straight to the patterns in Section 3 and use the examples as illustrations. If you prefer just wandering around and then looking at the map to see where you’ve been, try reading the examples through and refering to the patterns when you want more detail about a technique, then using the patterns as a reference.
Several reviewers have commented they got the most out of the examples when they started up a programming environment and entered the code and ran the tests as they read.
A note about the examples. Both examples, multi-currency calculation and a testing framework, appear simple. There are (and I have seen) complicated, ugly, messy ways of solving the same problems. I could have chosen one of those complicated, ugly, messy solutions to give the book an air of “reality.” However, my goal, and I hope your goal, is to write clean code that works. Before teeing off on the examples as being too simple, spend 15 seconds imagining a programming world in which all code was this clear and direct, where there were no complicated solutions, only apparently complicated problems begging for careful thought. TDD is a practice that can help you lead yourself to exactly that careful thought.
Clean code that works, in Ron Jeffries' pithy phrase, is the goal of Test-Driven Development (TDD). Clean code that works is a worthwhile goal for a whole bunch of reasons.
But how do we get to clean code that works? Many forces drive us away from clean code, and even from code that works. Without taking too much counsel of our fears, here's what we do: we drive development with automated tests, a style of development called Test-Driven Development (TDD). In Test-Driven Development, we
These are two simple rules, but they generate complex individual and group behavior with technical implications such as the following.
The two rules imply an order to the tasks ofprogramming.
Red/green/refactor--the TDD mantra.
Assuming for the moment that such a programming style is possible, it further might be possible to dramatically reduce the defect density of code and make the subject of work crystal clear to all involved. If so, then writing only that code which is demanded by failing tests also has social implications.
So the concept is simple, but what's my motivation? Why would a software engineer take on the additional work of writing automated tests? Why would a software engineer work in tiny little steps when his or her mind is capable of great soaring swoops of design? Courage.
Test-driven development is a way of managing fear during programming. I don't mea widdle prwogwammew needs a pacifiew-but fear in the legitimate, this-is-a-hard-problem-and-I-can't-see-the-end-from-the-beginning sense. If pain is nature's way of saying "Stop!" then fear is nature's way of saying "Be careful." Being careful is good, but fear has a host of other effects.
None of these effects are helpful when programming, especially when programming something hard. So the question becomes how we face a difficult situation and,
Imagine programming as turning a crank to pull a bucket of water from a well. When the bucket is small, a free-spinning crank is fine. When the bucket is big and full of water, you're going to get tired before the bucket is all the way up. You need a ratchet mechanism to enable you to rest between bouts of cranking. The heavier the bucket, the closer the teeth need to be on the ratchet.
The tests in test-driven development are the teeth of the ratchet. Once we get one test working, we know it is working, now and forever. We are one step closer to having everything working than we were when the test was broken. Now we get the next one working, and the next, and the next. By analogy, the tougher the programming problem, the less ground that each test should cover.
R Extreme Programming Explained will notice a difference in tone between Extreme Programming (XP) and TDD. TDD isn't an absolute the way that XP is. XP says, "Here are things you must be able to do to be prepared to evolve further." TDD is a little fuzzier. TDD is an awareness of the gap between decision and feedback during programming, and techniques to control that gap. "What if I do a paper design for a week, then test-drive the code? Is that TDD?" Sure, it's TDD. You were aware of the gap between decision and feedback, and you controlled the gap deliberately.
That said, most people who learn TDD find that their programming practice changed for good. Test Infected is the phrase Erich Gamma coined to describe this shift. You might find yourself writing more tests earlier, and working in smaller steps than you ever dreamed would be sensible. On the other hand, some software engineers learn TDD and then revert to their earlier practices, reserving TDD for special occasions when ordinary programming isn't making progress.
There certainly are programming tasks that can't be driven solely by tests (or at least, not yet). Security software and concurrency, for example, are two topics where TDD is insufficient to mechanically demonstrate that the goals of the software have been met. Although it's true that security relies on essentially defect-free code, it also relies on human judgment about the methods used to secure the software. Subtle concurrency problems can't be reliably duplicated by running the code.
Once you are finished reading this book, you should be ready to
This book is organized in three parts.
I wrote the examples imagining a pair programming session. If you like looking at the map before wandering around, then you may want to go straight to the patterns in Part III and use the examples as illustrations. If you prefer just wandering around and then looking at the map to see where you've been, then try reading through the examples, referring to the patterns when you want more detail about a technique, and using the patterns as a reference. Several reviewers of this book commented they got the most out of the examples when they started up a programming environment, entered the code, and ran the tests as they read.
A note about the exa Both of the examples, multi-currency calculation and a testing framework, appear simple. There are (and I have seen) complicated, ugly, messy ways of solving the same problems. I could have chosen one of those complicated, ugly, messy solutions, to give the book an air of "reality." However, my goal, and I hope your goal, is to write clean code that works. Before teeing off on the examples as being too simple, spend 15 seconds imagining a programming world in which all code was this clear and direct, where there were no complicated solutions, only apparently complicated problems begging for careful thought. TDD can help you to lead yourself to exactly that careful thought.
loading...
loading...
loading...
Terms of Use, Copyright, and Privacy Policy
© 1997-2009 Barnesandnoble.com llc