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.

 

Banner

 

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.

 

Banner


The C# Workshop (Packt)

Author: Jason Hales, Almantas Karpavicius and Mateus Viegas
Publisher: Packt
Date: September 2022
Pages: 780
ISBN: 978-1800566491
Print: 1800566492
Kindle: ‎ B0BGRBDJLS
Audience: C# developers
Rating:  4
Reviewer: Mike James
C# is not the language it once was - time for a revival?



Discovering Modern C++, 2nd Ed

Author: Peter Gottschling
Publisher: Addison-Wesley
Pages: 576
ISBN: 978-0136677642
Print: 0136677649
Kindle: ‎ B09HTJRJ3V
Audience: C++ developers
Rating: 5
Reviewer: Mike James

Modern C++ who would want to write anything else? Is this a suitable introduction for the rest of us?


More Reviews

Last Updated ( Tuesday, 03 April 2012 )