Framework Design Guidelines

Post on 12-May-2015

14834 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

Transcript

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

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

Dow Jones Industrial Average

@ 9,000

Dow Jones Industrial Average

@ 9,000

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

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

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

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

24

Time to cut…Time to cut…

26

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";

}

}

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

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

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

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?

Barbara Liskov

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

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

BCLBCL

WPFWPF XMLXML

ReflectionReflection

49Climbing a mountain?Climbing a mountain?

50

Scaling a Scaling a peak?peak?

51Running across a desert?Running across a desert?

Falling into a Falling into a pit?pit?

Read the manual??Read the manual??

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

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

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;}}}

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

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

Please fill out the session evals!

© 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.

top related