Test-Driven Database Development: Unlocking Agility Book Review
|I was a little wary of this book when I first saw it. No real specific red flag came up, just the general thought of yet another TDD book that magically unlocks agility.|
The author caught me by surprise as I started to read the book. He starts off with the way we need to change our view of databases from that of a particular instance into one of classes of databases. This line of thought is what enables TDD in the database world.
The third chapter he covers the differences and relationship between test-first programming and test-driven development. He gets you thinking in the right frame of mind about TDD.
The book continues with details of the practices and patterns you need to know to succeed at TDD with databases. I have listed the chapters below.
Chapter 1. Why, Who, and What
Chapter 2. Establishing a Class of Databases
Chapter 3. A Little TDD
Chapter 4. Safely Changing Design
Chapter 5. Enforcing Interface
Chapter 6. Defining Behaviors
Chapter 7. Building for Maintainability
Chapter 8. Error and Remediation
Chapter 9. Design
Chapter 10. Mocking
Chapter 11. Refactoring
Chapter 12. Legacy Databases
Chapter 13. The Façade Pattern
Chapter 14. Variations
Chapter 15. Other Applications
Through the process of showing us how to change our view of databases, the author introduces a way of building and deploying databases using XML scripts. He use XML to define the changes to the database, and a library he wrote to handle the parsing the XML and update the database. That technique is used throughout the book.
I mention that because it may be easy to miss when the author says "I’ll leave the implementation details to you, but I typically express the database design in terms of XML documents and store the already-applied versions in a table." I want to point that out because as you start going through the code it may get a bit overwhelming when you see how much work the author puts into the supporting library and XML documents. His tools include using NUnit also. There is an NUnit plug-in for Visual Studio 2012 available which makes running the tests and debugging while testing a lot easier.
The thing to keep in mind is that the author is introducing TDDD (Test Driven Database Design) practices and patterns and he is using the implementation method he has used for years. I accomplish the same thing as the author but I use Visual Studio's Unit Test Project template for tests, the SQL Server Database Project template for database scripts, and TFS for versioning, branching, and merging the tests and database scripts. The point is, keep reading because the author includes great advice throughout the entire book.
The code samples are very well organized and usable. After changing the connection strings and using NuGet to download Moq and NUnit, everything ran as expected. The author uses C# to write the tests and parse the XML he uses to define the database structure and changes.
The author's writing style makes the book an entertaining and enjoyable read.
Overall I highly recommend this book to developers, database administrators, enterprise architects, and software architects.
Test-Driven Database Development: Unlocking Agility