But Can It Work for Me on My System?

“What’s all this fuss about unit testing? It doesn’t seem to be helping me much.”

You might have already tried unit testing. Perhaps you are currently struggling with writing unit tests against your legacy system. Maybe it seems like TDD is OK for those rare other souls fortunate enough to be working on a new system. But does it solve your day-to-day problems of working on a long-entrenched, challenging C++ system?

Indeed, TDD is a useful tool but is no silver bullet for dealing with legacy systems. While you can test-drive many of the new features you add to your system, you’ll also need to begin chipping away at the years of accumulated cruft. You’ll need additional strategies and tactics for a sustained cleanup approach. You’ll need to learn about tactical dependency-breaking techniques and safe code change approaches that Michael Feathers presents in the essential book Working Effectively with Legacy Code [Fea04]. You’ll need to understand how to approach large-scale refactorings without creating large-scale issues. For that, you’ll learn about the Mikado Method [BE12]. This book will teach such supportive practices and more.

Simply adding unit tests for code you’ve already written (something I call Test-After Development [TAD]) usually has little impact as you struggle with “this is just how the system is.“ You might invest thousands of person-hours in writing tests with little measurable impact to system quality.

If you allow TDD to help you shape your systems, your designs will by definition be testable. They will also be different—in many ways, better—than if you did not use TDD. The more you understand what a good design should look like, the more TDD will help guide you there.

To aid you in shifting how you think about design, this book emphasizes principles that underlie good code management, such as the SOLID principles of object-oriented design described in Agile Software Development, Principles, Patterns, and Practices [Mar02]. I discuss how this sense of good design supports ongoing development and productivity and how TDD can help a mindful developer achieve more consistent and reliable results.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.82.4