.NET Fireside Chats - Brad Abrams and Krzysztof Cwalina
Join the DZone community and get the full member experience.Join For Free
dzone recently had an opportunity to sit down with brad abrams and krzysztof cwalina, authors of ' framework design guidelines: conventions, idioms, and patterns for reusable .net libraries, 2nd edition ' in this interview, they discuss some best practices for developers to follow when designing and exposing their own frameworks.
dzone - tell us a little about what you do at microsoft?
brad abrams - i am a product unit manager for parts of the .net framework in particular the line-of-business story for silverlight as well as the managed extensibility framework. but i am not sure that tells you what i do… i create joy for developers using the .net framework.. i relish identifying the emerging demands in software development and creating frameworks that makes developers lives easier!
krzysztof cwalina - i am program manager on the .net framework team. i lead a team responsible for the general framework design and architecture, and some apis in the base libraries.
dzone - what motivated you to write the first edition of this book?
brad - krys and i have been working on these guidelines sense nearly the first day development of the what would later become the .net framework. i was designing parts of the base class library such as string and object. in doing so i realized that for developers to really have joy while using our framework, we needed consistency across the framework, so asp.net, winforms, ado.net all needed to follow the same style and naming conventions. so krys and i began working on these guidelines as an internal specification. we had some success at that, but i never considered doing a book. a few years later, after .net framework 1.0 shipped i had a chance to go meet with several companies and spend one week at a time with several development teams in their work place. i was amazed that so many of the issues they were debating and struggling with were already covered in the internal document we had been working on. when i came home, we quickly started working on polishing the specification up into book format.
krys - when i started designing apis for the .net framework i searched for available resources on the subject of api design. there were close to none. there were some very good api designers at microsoft who knew how to do design great apis, but the knowledge was distributed and not easily accessible. i thought it would be great to gather the knowledge in one document, and make it available to everybody in a form of a book.
dzone - why did a second edition become necessary?
brad - there were a couple of forces pushing on the need for a 2nd edition. the most important one was new innovations in the .net framework created new patterns and options for .net developers. we believed that new frameworks should certainly start to follow those new patterns. innovations such as linq fall into that category. the other force was that the software development industry continues to mature – new patterns are becoming mainstream that affect the way frameworks are designed. patterns such as test-driven development fall into that category.
krys - since the release of the first edition, we learnt how to explain some api design concepts better, so in addition to the changes resulting from new additions of the platform, some sections and chapters were updated to provide clearer guidance.
dzone - what constitutes a 'framework'?
brad - i think of a framework as being a set of code that is explicitly designed for use by someone else who is often separated by time or space. if you are just writing some code for yourself to use right away, you can keep a lot of things in your head about the intended usage. however if you are writing some code that someone else will have to consume, maybe someone you have never meet, maybe someone that can’t practically speaking talk to you, the only way you have to communicate with them is via the design of the framework.
krys - i am just going to quote directly from the book: framework is a large object-oriented reusable library. i know some people say that framework call user code and user code calls libraries, but i think the distinction is not interesting anymore, as there are not many reusable libraries that do not call back to user code.
dzone - what are some of the hardest problems that developers are trying to solve when it comes to designing frameworks?
brad - communication. framework designers have some intended usage pattern, some scenarios for how their framework can best be used. communicating that to the consumers of the framework is really hard. documentation is very one dimensional, samples and quick starts show only one narrow path through, there are millions of combinations you miss. having direct one-on-one chats is the best way to communicate this sort of thing, but it clearly doesn’t scale. by using the standard set of patterns that both the product and consumer understand, the communication channel can be greatly streamlined. the fdg attempts to connincalize these patterns.
krys - getting designs that are both simple and powerful. you can accomplish this with proper layers of abstraction, but it’s hard. it requires a combination of experience, passion, prototyping, modeling, and getting continuous feedback from customers who will end up using these apis.
dzone - how did you compile these guidelines? past experiences, microsoft practices, industry standards?
brad - there is a wide variety of sources. krys and i get lots of comments on our blogs we talked to customers directly about what works and what doesn’t. nearly every day some framework designer at microsoft contacts us with a new suggestion or new problem that spurs a suggestion. i’d say very few if any of these guidelines are my original thoughts. early in the process the single biggest contributor to the guidelines, in fact the person that set the tone for the overall philosophy was anders hejlsberg who was also the lead designer for the c# language.
krys - my team conducts api reviews of all apis that we ship in the .net framework and many shipped by other teams at microsoft. the review process is a gold mine for hard api design problems and potential solutions. if a design issue (like when to use classes and when interfaces) is discussed more than a couple of times at a review, i put in on a list of candidates to write a guideline about.
dzone - how have new .net framework 3.x features impacted your view of design best practices?
krys - the core principles and the overall philosophy of how we design frameworks have not changed much. some details have changed as a result of advances in the base class libraries. for example, linq had a relatively significant impact on how we are designing apis manipulating sets of data.
dzone - do you think a lot of the developers on the .net framework team have this book on their stack?
brad - oh quite a few of them do, but then many of the come by my office to borrow my copy or more often just use me as a human version of the book ;-). krys also teaches a class regularly at to microsoft engineers that is very well received… the book is certainly well known on the .net framework team.. but i have still yet to hear chapter-and-verse quoted in a design meeting.. i’d love to hear that!
krys - yeah, many of them do and they often us it; like in “hey krzysztof, your proposed design is stupid. go check your book.” :-)
dzone - are these guidelines specific to .net developers, or do they cross language barriers?
brad - well, we certainly focused on the .net environment, so it is very easy to see how it applies to all the .net languages. but we have actually heard from many java developers that the design principles are the same and i know it i used in some java shops! so i think the guidelines are more universal, though all the examples are in my favorite programming language: c#!
krys - i would say half of the book’s content is pretty universal. the other half is specific to .net, but only a very small percentage is language specific.
dzone - are there any interesting case studies that you can discuss? have you implemented a recent project using these guidelines?
krys - yes, my team works on a new .net framework 4.0 feature called managed extensibility framework. the feature is not done yet, but i think it’s a pretty good example of what apis designed with the guidelines in mind look like. the apis are well factored, easy to use in common scenarios and powerful enough to support advanced scenarios. similarly there are new concurrency related apis being added to the framework in the next version and i know the team concurrency team is big on the guidelines.
dzone - who should buy your book?
brad - you should buy this book only if you want to be a better developer. if you are designing frameworks, this book will help you know what to avoid and what patterns to follow. if you are building applications this book will help you understand what philosophy governs how the frameworks are built… it will also help you quickly spot bad, or poorly designed frameworks so you can fix or stay away from them!
dzone - do you have any future books in the works? a third edition?
brad - oh my… well, like my wife said just after our son was born: “now is not a good time to ask me that!”
krys - nothing in the works and no plans for now. writing a book while holding a full time job is really though. the satisfaction from seeing your book in print, especially when it comes out successful, is huge, but none the less too many long nights to do it often.
Opinions expressed by DZone contributors are their own.