Book Reviews

Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition) by Krzysztof Cwalina and Brad Abrams

ISBN: 0321545613
Publisher: Addison-Wesley Professional
Pages: 480

Consistency is a key-characteristic of all well-designed software. Consistency is also one of the most challenging aspects of any large-scale project. As such I've came to view the main purpose of software architecture more as a set of principles and guiding decisions towards consistency and conceptual integrity rather than taking the traditional and largely dysfunctional view of architecture as a system blueprint. Such a set of architecture and design principles would ideally represent a layered model. A model that goes all the way down to individual classes and functions. To those lower layers, Framework Design Guidelines provides an excellent basis for API consistency on both syntactic and semantic levels.

Over the years I've met a lot of coding standards at different companies. What most of these standards have in common is that they're dated, sometimes lagging years behind best practices, contain frequent inaccuracies, and are largely ignored. Given that background, this book provides a refreshing read. Both of its authors have been involved in the development of the .Net framework. In this book they've put together a valuable collection of lessons learned, idioms and guidelines for C# development. Framework Design Guidelines covers the complete design space with respect to API design. The topics range from the detailed (designing custom event handlers, overloaded operators, etc), over the semantic distinctions between different alternatives (e.g. when to use properties and methods respectively, scenarios for extension methods), all the way to more complex patterns like correct resource management and variations on the Async patterns. The book is deliberately weak on the actual implementations behind the API. It's not a tutorial or reference on object-oriented design. Instead it's a complement to our existing design skills that guides us towards idiomatic constructs as prevalent in the .Net community. That's an important space to fill.

An interesting touch is the annotations provided by well-known architects and developers at Microsoft. Their comments on the various topics are worth the price of the book alone. Unlike many coding standards this perspective allows us to get into the rationale behind the recommendations. My favorite discussions are the ones that focus on possible alternatives that were once considered. Other valuable annotations describe how the designers initially got something wrong and later changed their minds as they learned more about the problem. Not only does it make me feel better about my own ever-changing opinions and design approaches; it also reinforces the idea that design is inherently iterative in its very nature. In design, true understanding is grown by carrying out actions and reflecting upon the results.

If there's one problem with the book it's the misleading title (Framework Design Guidelines). Besides the introductory prose on the principles of frameworks, the book contains very little material that I would consider framework-specific. It's more about designing robust classes and functions in idiomatic C#. The focus is on the public parts of the design artifacts, the parts that matters to a programmer using your code. That's also the part that matters most in object-oriented designs. Not only is it the most expensive aspect to change; it's also the one with potential to carry a lot of communication value. After all the core of object-orientation is about protocols between objects. Thus I would recommend the guidelines to all application programs written in C#.

Framework Design Guidelines is a solid book to base your company- or product-specific coding standard on. There's one caveat though. The book is dated in that it covers .Net version 3.5. Both .Net and C# has evolved at a rapid pace since then. A modern C# programmer would need additional guidelines and deprecate some of the ideas presented in this book. Since I happen to target the Compact Framework at the moment, I'm stuck with .Net 3.5. So to me this somewhat dated edition is more of a feature than a problem. But I do hope we get to see another updated edition of this book. If you're a C# developer this book is a highly recommended read that I wish I'd found earlier. It's the kind of work that deepens your understanding of the technology.

Reviewed April 2013