Top Banner
Krzysztof Cwalina Program Manager Microsoft Corporation http://blogs.msdn.com/k cwalina Brad Abrams Product Unit Manager Microsoft Corporation http://blogs.msdn.com/b rada
79

Framework Design Guidelines

May 12, 2015

Download

Technology

brada

I am very excited to be giving a Framework Design Guidelines talk at the PDC this year. Krzysztof and I think of this as our "victory lap" for publishing the Framework Design Guidelines 2nd Edition.
As we were talking about what to cover in this talk, Krys and I realized that it has been just about 10 years since we started that very first version of the Framework Design Guidelines. This is well before we started working on the book, in fact it was before .NET Framework 1.0 shipped or was even announced (which, btw, was at PDC2000).

We got to thinking about how things have changed, both in the guidelines and in the industry. Equally interesting is how much has stayed the same. I am particularly interested in what stayed the same over that time.. As we wrote even those first guidelines we knew it was very important that they last. In fact, we needed them to be timeless. About the same time a friend was in the process of designing and building her own home and she gave be a book that still shapes the way I think about software design today: Christopher Alexander, The Timeless Way of Building.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Framework Design Guidelines

Krzysztof CwalinaProgram ManagerMicrosoft Corporationhttp://blogs.msdn.com/kcwalina

Brad AbramsProduct Unit ManagerMicrosoft Corporationhttp://blogs.msdn.com/brada

Page 2: Framework Design Guidelines
Page 3: Framework Design Guidelines

Dow Jones Industrial Average

@ 9,000

Page 4: Framework Design Guidelines

Dow Jones Industrial Average

@ 9,000

Page 5: Framework Design Guidelines
Page 6: Framework Design Guidelines
Page 7: Framework Design Guidelines

Framework Design Framework Design Artifacts:Artifacts:• PropertiesProperties• Methods Methods • EventsEvents• ConstructorsConstructors

Page 8: Framework Design Guidelines

8

public class XmlFile {public class XmlFile { string filename; string filename; Stream data; Stream data; public XmlFile(string filename) { public XmlFile(string filename) { this.data = DownloadData(filename); this.data = DownloadData(filename); }}}}

public XmlFile(string filename) {public XmlFile(string filename) { this.filename = filename; this.filename = filename; } }

lazylazy

Page 9: Framework Design Guidelines

public class ArrayList {public class ArrayList { public int Count {get;} public int Count {get;}}}

Page 10: Framework Design Guidelines
Page 11: Framework Design Guidelines

EmployeeList l = FillList();EmployeeList l = FillList();for (int i = 0; i < l.Length; i++){for (int i = 0; i < l.Length; i++){ if (l.All[i] == x){...}if (l.All[i] == x){...}}}

if (l.GetAll()[i]== x) {...}if (l.GetAll()[i]== x) {...}

public Employee[] All {get{}}public Employee[] All {get{}}

public Employee[] GetAll() {}public Employee[] GetAll() {}

Moral: Use method if the operation is expensive Moral: Use method if the operation is expensive

Calling CodeCalling Code

Page 12: Framework Design Guidelines
Page 13: Framework Design Guidelines
Page 14: Framework Design Guidelines
Page 15: Framework Design Guidelines
Page 16: Framework Design Guidelines
Page 17: Framework Design Guidelines
Page 18: Framework Design Guidelines
Page 19: Framework Design Guidelines
Page 20: Framework Design Guidelines
Page 21: Framework Design Guidelines
Page 22: Framework Design Guidelines
Page 23: Framework Design Guidelines
Page 24: Framework Design Guidelines

24

Page 25: Framework Design Guidelines

Time to cut…Time to cut…

Page 26: Framework Design Guidelines

26

Page 27: Framework Design Guidelines
Page 28: Framework Design Guidelines
Page 29: Framework Design Guidelines
Page 30: Framework Design Guidelines

public class TheBase : Object {

public override string ToString() {

return “Hello from the Base";

}

}public class Derived : TheBase {

public override string ToString() {

return “Hello from Derived";

}

}

Page 31: Framework Design Guidelines

Derived d = new Derived();Console.WriteLine (d.ToString());

TheBase tb = d;Console.WriteLine (tb.ToString());

Object o = tb;Console.WriteLine (o.ToString());

Page 32: Framework Design Guidelines
Page 33: Framework Design Guidelines

All Virtual members should define a contractAll Virtual members should define a contractDon’t require clients to have knowledge of Don’t require clients to have knowledge of your overridingyour overridingShould you call the base?Should you call the base?

Page 34: Framework Design Guidelines

Barbara Liskov

Page 35: Framework Design Guidelines

public interface IComparable { int CompareTo(object obj);}

Page 36: Framework Design Guidelines
Page 37: Framework Design Guidelines
Page 38: Framework Design Guidelines

Careful dependency management is the necessary ingredient to successful evolution of frameworks. Without it, frameworks quickly deteriorate and are forced out of relevance prematurely.

Page 39: Framework Design Guidelines
Page 40: Framework Design Guidelines

BCLBCL

WPFWPF XMLXML

ReflectionReflection

Page 41: Framework Design Guidelines
Page 42: Framework Design Guidelines
Page 43: Framework Design Guidelines
Page 44: Framework Design Guidelines
Page 45: Framework Design Guidelines
Page 46: Framework Design Guidelines
Page 47: Framework Design Guidelines
Page 48: Framework Design Guidelines
Page 49: Framework Design Guidelines

49Climbing a mountain?Climbing a mountain?

Page 50: Framework Design Guidelines

50

Scaling a Scaling a peak?peak?

Page 51: Framework Design Guidelines

51Running across a desert?Running across a desert?

Page 52: Framework Design Guidelines

Falling into a Falling into a pit?pit?

Page 53: Framework Design Guidelines
Page 54: Framework Design Guidelines
Page 55: Framework Design Guidelines
Page 56: Framework Design Guidelines
Page 57: Framework Design Guidelines
Page 58: Framework Design Guidelines
Page 59: Framework Design Guidelines
Page 60: Framework Design Guidelines
Page 61: Framework Design Guidelines
Page 62: Framework Design Guidelines
Page 63: Framework Design Guidelines

Read the manual??Read the manual??

Page 64: Framework Design Guidelines
Page 65: Framework Design Guidelines
Page 66: Framework Design Guidelines
Page 67: Framework Design Guidelines
Page 68: Framework Design Guidelines
Page 69: Framework Design Guidelines

PPascalascalCCasing – Each asing – Each word starts with an word starts with an uppercase letteruppercase letter

ccamelamelCCasing – First asing – First word lower case, word lower case, others uppercaseothers uppercase

SCREAMING_CAPSSCREAMING_CAPS – – All upper case with All upper case with underscoresunderscores

Page 70: Framework Design Guidelines

public class MemberDoc{ public int CompareTo(object value) public string Name { get;}}

Page 71: Framework Design Guidelines

public class CMyClass {public class CMyClass { int CompareTo (object objValue) {..} int CompareTo (object objValue) {..} string lpstrName {get;} string lpstrName {get;} int iValue {get;} int iValue {get;}}}

Page 72: Framework Design Guidelines
Page 73: Framework Design Guidelines
Page 74: Framework Design Guidelines
Page 75: Framework Design Guidelines
Page 76: Framework Design Guidelines
Page 77: Framework Design Guidelines
Page 78: Framework Design Guidelines

Brad Abramshttp://blogs.msdn.com/brada

Krzysztof Cwalinahttp://blogs.msdn.com/kcwalina

Please fill out the session evals!

Page 79: Framework Design Guidelines

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.