Reviewed: May 2013
Martin Reddy has written a very useful book on the art and science of Application Programming Interfaces (APIs), and along the way has produced a book chock full of useful hints and help for more junior programmers. It is not a book for someone wanting to learn to program in C++, but if you have been programming in C++ for a year or so, then you will find this book will help you move toward towards program design instead of just ‘coding’.
Obviously, the book concentrates on API design, but along the way it covers selected patterns, API styles, performance, testing and documentation. As a bonus it also covers scripting and extensibility, and I found the section on plugins particularly useful. An appendix covers the varied technical issues involved in building both static and dynamic libraries on Windows Mac and Linux.
The only minor disagreement I would have with the author is with the extent to which he goes to move internal details out of header files in the name of preventing the API users from doing anything that might allow them to access those features. From my point of view, using the API is a type of contract between the API writer and the API user. If the user is foolish enough to break that contract then he or she has to take the consequences in terms of broken code when a new version of the library comes out. In any case this sort of behaviour should be picked up by code review in any halfway decent software studio.
That is, however, a minor niggle, and this book represents a rich seam for programmers to mine for good programming practices – even if you aren’t writing API, your use of them will improve dramatically!