Bob Martin's Foreword to Test-Driven Development for Embedded C
You’ve picked up this book because you are an embedded software engineer. You don’t live in the programmer’s world of multicores, terabytes, and gigaflops. You live in the engineer’s world of hard limits and physical constraint and of microseconds, milliwatts, and kilobytes. You probably use C more than C++ because you know the code the C compiler will generate. You probably write assembler when necessary because sometimes even the C compiler is too profligate.
So, what are you doing looking at a book about Test-Driven Development? You don’t live in the kind of spendthrift environment where programmers piddle around with fads like that. Come on, TDD is for Java programmers and Ruby programmers. TDD code runs in interpreted languages and virtual machines. It’s not for the kind of code that runs on real metal, is it?
James Grenning and I cut our teeth on embedded software in the late 70s and early 80s. We worked together programming 8085 assembler on telephone test systems that were installed in racks in telephone central offices. We spent many an evening in central offices sitting on concrete floors with oscilloscopes, logic analyzers, and prom burners. We had 32KB of RAM and 32KB of ROM in which to work our miracles. And boy, what miracles we worked!
James and I were the first to introduce C into the embedded systems at our company. We had to fight the battles against those hardware engineers who claimed “C is too slow.” We wrote the drivers, the monitors, and the task switchers that allowed our systems run in a 16-bit address space split between RAM and ROM. It took several years, but in the end, we saw all the newer embedded systems at our company written in C.
After those heady days in the 70s and 80s, James and I parted company. I wandered off into the realms of IT and product-ware, where resources flow like wine at an Italian wedding. But James had a special love for the embedded world, so for the past thirty+ years James Grenning has been writing code inembedded environments such as digital telephone switches, high-speed photocopiers, radio controllers, cell phones, and the like.
James and I joined forces again in the late 90s. He and I consulted at Xerox on the embedded C++ software running on 68000s in Xerox’s high-end digital printers. James was also consulting at a well-known cell phone company on its communications subsystems.
As accomplished as James is as an embedded software engineer, he is also an accomplished software craftsman. He cares deeply about the code he writes and the products he produces. He also cares about his industry. His goal has always been to improve the state-of-the-art in embedded development.
When the first XP Immersion took place in 1999, James was there. When the Agile Manifesto was conceived in Snowbird in 2001, James was there and was one of the original signatories. James was determined to find a way to introduce the embedded industry to the values and techniques of Agile soft- ware development.
So, for the past decade, James has participated in the Agile community and worked to find a way to integrate the best ideas of Agile software development with embedded software development. He has introduced TDD to many embedded shops and helped their engineers write better, more reliable, embedded code.
This book is the result of all that hard work. This book is the integration of Agile and embedded. Actually, this book has the wrong title. It should be Crafting Embedded Systems in C because although this book talks a lot about TDD, it talks about an awful lot more than that! This book provides a very complete and highly professional approach to engineering high-quality embedded software in C, quickly and reliably. I think this book is destined to become the bible of embedded software engineering.
Yes, you can do TDD in the embedded world. Not only that, you should! In these pages, James will show you how to use TDD economically, efficiently, and profitably. He’ll show you the tricks and techniques, the disciplines, and the processes. And, he’ll show you the code!
Get ready to read a lot of code. This book is chock-full of code. And it’s code written by a craftsman with a lot to teach. As you read through this book and all the code within it, James will teach you about testing, design principles, refactoring, code smells, legacy code management, design patterns, test pat- terns, and much more.
And, on top of that, the code is almost entirely written in C and is 100 percent applicable to the constrained development and execution environments of embedded systems.
So, if you are a pragmatic embedded engineer who lives in the real world and codes close to the metal, then, yes, this book is for you. You’ve picked it up and read this far. Now finish what you started and read the rest of it.
Robert C. Martin (Uncle Bob) October 2010