Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries: Video Podcast Transcript
View the original Video Podcast.
Welcome to OnMicrosoft—conversations with thought leaders in Microsoft technologies. In this session, Brad Abrams and Krzysztof Cwalina discuss Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, Second Edition, the definitive resource for .NET developers and architects designing class library frameworks—updated for the new language features of the .NET Framework 3.0 and 3.5.
Brad Abrams: Hi, I'm Brad Abrams, an employee at Microsoft. I'm here at the sunny Redmond campus [with my coauthor Krzysztof Cwalina], talking about our new book, Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, Second Edition. Krzysztof, what do you think are the key new things that we got a chance to put in this [edition]?
Krzysztof Cwalina: We published the first edition of the book several years ago, and that was right after .NET Framework, I think 2.0 or so.
Brad: [Version] 2.0 had just shipped, yeah.
Krzysztof: The book was really successful, people found it useful, but now the framework moved forward. We have new features both in the runtime and in the core platform, and there was just a need to update [the book]. The framework has changed, and the rules for designing libraries that integrate well with the framework have changed.
Brad: [We've made] a bunch of additions to the book, but I was impressed that even after the last six or so years as we've been seriously working on the guidelines, I don't think a single guideline substantively changed. We added a bunch of new [guidelines], but by and large the body of work stayed the same.
Krzysztof: The guidelines are like framework libraries—you don't want to break framework libraries as [you go] to release. And to avoid breaking changes, you cannot change the rules [in] the way you design the framework. You cannot tell people, "This is how you design today. And, by the way, next version, your design is going to be wrong." Correct?
Brad: Yeah, yeah.
Krzysztof: So we are very careful about avoiding resets. That requires a lot of thought before we actually put guidelines into the official book. We do it by basically trying things in real life, in the real framework; doing postmortem or thinking about how we arrived at the design—what were the good parts of the design, what [were] not; and then applying those guidelines.
Brad: Another classic example: [For] several sections of the book in the first edition, we got feedback [that] some things were harder to understand, and we were having to explain more than we like. For example, the exceptions section [got a wholesale rewrite]. Didn't change any of the guidelines, but certainly explained things in a lot clearer manner.
Krzysztof: Yeah, exactly. Exceptions design is something that you know many books and articles have been written about, and it's a very difficult subject. I think our first attempt at describing the exception space was a good effort.
Brad: Valiant effort.
Krzysztof: But some parts of the exceptions chapter were not explaining the issues in an easy-to-understand way. After a few years of experience, we know how to explain it better, and that was one of the chapters that was significantly updated.
Brad: You mentioned that we wrote [the first edition of] this book shortly after .NET Framework 2.0 shipped. The second edition basically covers the framework features that we put in since then. We're not teaching how to use these features; what we're doing is saying—based on years and years of experience, from countless people using the features—the best practices that have emerged. For example, we have some LINQ usage guidelines.
Krzysztof: Yes—but, as you said, they're not about how to use LINQ. They're mostly about, "I want to integrate my library with LINQ—and what are the API design techniques and maybe interfaces that I need to implement to achieve integration?"
Brad: Overall the book is a good mix of philosophical design points ("Generally, this is how to think about this") as well as super-pragmatic things ("Implement this interface, throw this exception")—you know, very concrete, so I think the book does a good job of tying those together.
Krzysztof: Exactly. I think that's the main value of the book. As you said, there are many books that describe framework features and how to use them.
Brad: Right.
Krzysztof: We could not create a book that is the definitive guide to using the .NET Framework—every single feature that you see in the .NET Framework.
Brad: We should work on that next—that should be our next tome.
[Both laugh.]
Krzysztof: But what we attempted to do was create a book that is the definitive guide for creating crosscutting kind of designs in framework libraries.
Brad: Yeah, yeah.
Krzysztof: But now, the danger is going too far into the philosophy. We wanted to avoid [that], and that's why the format of the book is such that we have very actionable guidelines. Basically there is almost no prose—"Oh! We think that this is the philosophy," and whatnot. A majority of the book is basically simple bullets: Do that, do not do this, avoid that, consider doing this. And of course justification is very important, so for each of these bullets we have justification—because, frankly, I myself cannot follow rules, unless I understand the reason behind the rule.
Brad: Yes.
Krzysztof: So those are the kind of elements or techniques that we use to explain [the] sometimes very difficult concepts in framework design.
Brad: Absolutely. People at conferences [have told me] that this book is very well suited to give to line developers and say, "This is our best practices." Put it on their desk, and they can make sense of it and apply it directly. The other thing this [book] does is—you know, people have these guidelines. Every company, every group has a set of guidelines. We save you hours of argument. You don't have to argue about these things [because you can just follow] what it says in the book. At least you know then that you're going to be consistent with the bulk of the .NET Framework. The purpose, the reason we wrote [the book] is to help Microsoft build out the actual .NET Framework. It's sort of a side benefit that we get a book out of it.
Krzysztof: Exactly. Half of the guidelines are basically what I call "conventions." I was talking about having a reason. For many of those [conventions], the reason is, this is how we chose to design libraries. You know, there is no better or worse way. [For example,] case identifiers: We just chose one way, and the reason for following the guideline is being consistent.
Brad: That's right.
Krzysztof: Then there's a second set of guidelines, which are basically written after our experiences of designing one of the largest reusable frameworks ever created. Not many people could experience designing something like that. [A] lot of people in the .NET Framework team contributed [to the guidelines]; they were the domain experts for many of the guidelines. The book is basically holding the common knowledge of designers of the .NET Framework.
Brad: I think of us as the custodians of the knowledge. Whenever we write this book, we are the custodians—we help gather it, put it together. As you said, there were people who contributed directly, actually wrote the section, and then we also benefit from just being around there working with lots of people who are designing parts of the framework, designing those features, and we can make sure that there's very direct "first person" input on what we've done.
Krzysztof: Right.
Brad: The other thing I really like about the book is the annotation section. Many of the guidelines could be a little dry at times, so having annotations by leading industry experts really gives some color and some flavor to the text.
Krzysztof: Going back to the rationale behind the guidelines: No matter how much we could write rationale below the bullet describing a rule, [because] we didn't have that many annotations it was very difficult to convey all the tradeoffs that you have to make, and tradeoffs are a big part of the rationale.
Brad: Absolutely.
Krzysztof: I think by having annotations from experts, sometimes disagreeing with each other—
Brad: Not disagreeing, [more] a kind of nuanced opinion.
Krzysztof: Exactly. Having slightly different opinions points at the tradeoffs that API designers have to make, even if they apply some of the "do or do not" guidelines.
Brad: Absolutely. Well, it was good to talk to you about the book; looking forward to maybe [a third edition] sometime.
Krzysztof: Yeah, maybe. Or maybe this big stack of books about how to use the .NET Framework.
Brad: Yeah, yeah. We'll get right on that.
For more information, visit onpodcastweekly.com and subscribe to all our podcasts. Brought to you by the publishing imprints and information portal of Pearson Education.