Test Driven Development for Embedded C

Author:James W. Grenning
Publisher: Pragmatic Bookshelf, 2011
Pages: 310
ISBN: 978-1934356623
Aimed at:  C programmers
Rating: 4.5
Pros: Clear and persuasive
Cons: Not as low level as "embedded" might suggest
Reviewed by: Harry Fairhead


The idea of using any sort of programming methodology in the essentially crude world of embedded development might seem unlikely but in this case we have something to learn.

If only all of the programming books I had to read were as straight to the point as this one. Even if you don't write embedded code this is a great introduction to Test-Driven Development in C. In fact you might even complain that there isn't enough about embedded development but I don't think this matters too much. The orientation of the book is towards small resource limited systems.

The book starts off with a look at the basic idea of TDD and manages to "sell" the need for it as well as the principle quite well. From here we move on to specific test toolkits - Unity, CppUTest and examples of using them. Chapter three takes us though an example of TDD in building an LED driver. Then we move on to the particular problems of embedded TDD and how to cope with the hardware problem.

After this you get to a point where you should understand the ideas and approach of TDD but probably are still resistant to it because of issues of efficiency, the time it takes to write and maintain test and so on. Chapter 6 attempts to anticipate these objections and explain why they are not as important as you might at first think.




Part II of the book is about testing with collaborators i.e. other modules that the test module is dependent on. This is about the problems of "mocking" when it comes to hardware or code that isn't available to be part of the testing. If you already know something about TDD this provides much of the modification you need to make it possible to see how to adapt what you know to the embedded situation. Part II is about design and continuous improvement. The topics covered include refactoring, adding tests to legacy code and patterns and antipatterns.

Overall this is a book that puts a convincing case for TDD - and suceeds in making it seem reasonable in an embedded environment. It is well written with plenty of well formatted code illustrating the ideas.

What it doesn't do is to tackle the extremely low level problems that an embedded system can encounter - DMA, interrupts and so on. If you are looking for a book that deals with chip level programming and simulation then this isn't it - but not all embedded programming has the exceptionally low level feel to it. Even when it does there will usually be a large chunk of the program that doesn't deal with low level concerns - routines that deal with dates say rather than the RTC hardware. In this sense the book is more about TDD in C with limited resources than about interacting with hardware in intimate ways.

So what you think of the book does depend on the sort of embedded code you are creating.Personally I'm prepared to overlook the defects and recommend it to any C programmer even if they aren't specifically designing embedded code.



Adventures of a Computational Explorer

Author: Stephen Wolfram
Publisher: Wolfram Media
Pages: 432
ISBN: 978-1579550264
Kindle: B07Z6BYVSC
Audience: Fans of  Stephen Wolfram
Rating:  3
Reviewer: Alex Armstrong
A personal account of being a computer geek?

Python Programming with Design Patterns

Author: James W. Cooper
Publisher: Addison-Wesley
Date: February 2022
Pages: 352
ISBN: 978-0137579938
Print: 0137579934
Kindle: B09D2RKQB5
Audience: Python developers
Rating: 1
Reviewer: Mike James
There was a time that design patterns were all the thing. Not so much now. But Python - does it have [ ... ]

More Reviews

Last Updated ( Tuesday, 03 April 2012 )