Delphi Programming

and software in general.

Friday, December 12, 2008

Review: Framework Design Guidelines, 2nd Ed. by Krzysztof Cwalina and Brad Abrams

Subtitle: "Conventions, Idioms, and Patterns for Reusable .NET libraries". Highly relevant to Delphi Prism users, but you can very well eliminate that .NET part and apply this to writing libraries for Win32 using Delphi 2009 as well (or any prior Delphi version, for that matter).

When you write code with the intent of making it public and reusable, there are certain aspects of designing classes, interfaces, types and so forth, where we really need experience to come up with easy to understand and easy to use code. This book delivers 6 years worth of wisdom and experience from the .NET teams and we can all do well by picking their brains for reusable knowledge.

The book present a sensible set of lessons learned and goals to strive for. Without lecturing, and always exemplifying - we get a step by step journey through the different aspects of designing a framework. It is concisely written and easy to read, and it is not without humor.

The book is richly commented by the developers themselves, embellishing on the guidelines, sometimes including design regrets and mistakes made, and sometimes also hinting towards why you might want to break a guideline under certain conditions.

As Anders Hejlsberg write in the foreword: "The guidelines have served us well through three versions of the .NET Framework and numerous smaller projects, and they are guiding the development of the next generation of APIs for the Microsoft Windows operating system".

I won't delve into all the details of the content, but it covers the basics of how to design a framework by being roleplaying the consumer as well as testing it on your peers, good naming, type design, member design, extensibility, exceptions, as well as usage guidelines. It rounds off with a collection of common patterns such as aggregate components, async patterns, dependency properties, dispose pattern, factories, and many more. There is also a brief C# coding style convention section and a tutorial on using FxCop to enforce the framework design guidelines.

The book is not C# centric, but embellish the fact of .NET being a multi-lingual platform, and remind you to avoid certain constructs that may be too tightly bound to a specific language.

"Framework Design Guidelines (2nd Ed.)" by Krzysztof Cwalina and Brad Abrams (Addison-Wesley ISBN-13: 978-0-321-54561-9) falls under the collection of books that I wish I had available to read when I started out coding. Together with "Code Complete (2nd Ed.)" by Steve McConnell, it should be mandatory reading for every developer, regardless of language or development niche.

Highly recommended.

Programming Related Blogs