http://www.arload.net
Framework is ..
Framework is…
          is…
Douglas C. Schmidt Says..
Frameworks define “semi-complete” application
                  “semi-
that embody domain-specif...
Libraries is..
                                       Application Block
                                    DATABASE      ...
But Framework is ..

                              Active Object                  State

                         NETWORKI...
Why Do You Need Framework?




Avoid Duplication   Productivity
Welcome to
My Framework
      Journey!
“Framework Engineering”, TechED 2007 Europe
“Framework Design Guidelines” , Addison Wesley

Krzysztof Cwalina
Program Mana...
5 Topics..

                   Development       Organization




                 Design                     Planning



...
The most powerful design tool




                                O
Project Management Triangle

             Scope




     Cost             Time

                              O
Organization


Project Management Triangle
                                   O
 DO understand how organizational structure,
  culture, and decision making processes impa
  ct your product.




       ...
Conway's law


If you have 4 groups working on a compiler,
you’ll get a 4-pass compiler.
                                 ...
Organization   Software
 Structure     Structure




                           O
Conway's Clean State Approach
       • Define the business mission
   1


       • Learn the business process from busines...
Your Company Culture Is ..




              Voluntary ??   O
Your Company Culture Is ..




             Familial ??
                             O
Peremptory   O
Organizational Influences
Size of Organization


                         Simple Design

                       Consistenc...
Organizational Influences
Size of Organization

                        Powerful Design

                        Lack Cons...
Organizational Influences
Organization’s Culture/Biases


                                Customer-Focused



            ...
Organizational Influences
Organization’s Culture/Biases



   Technology-Focused



 Long Lasting Architecture



        ...
Decision Making Process is..




                               O
Ensuring we are building the right thing




                                           P
P
Peanut Butter          Skyscrapers




Focus: features       Focus: scenarios
Results: stability,   Results: Excitement,
i...
Moderation (中庸)
           (中庸)
MileStone = Scenarios + Feature

           Vision statement             Feature complete ...
Ensuring the long term health of the framework




                                                 A
Right Way??
   Choose right types.




                         A
Taxonomy of Types
Libraries , Primitives, Abstractions




                                       A
Primitives
 Very little policy (behavior design decisions)
 Stable design
 Commonly appear in publicly accessible APIs
 Al...
Libraries
 Definition:
    Libraries are types that are not passed between com
    ponents
 Examples
    EventLog, Debug,
...
Abstractions
 Definition:
    Abstractions are interfaces or classes with unsealed member
    s that are passed between co...
Primitive Oriented Design
 A.K.A. “Handle based design” (functional)

 Great evolvability, poor usability (sometimes)

 Lo...
for primitive..
C# 3.0 New Feature
namespace MyCompany.StringManipulation {
    public static class StringExtensions{
    ...
Component Oriented Design

 Rich APIs with lots of features, thus with lots of dependencies

 Great usability, poor evolva...
 DO Manage Dependencies..

                             A
Component is ..




                  Lego, Plug ??
                                  A
.. a set of types that ship and evolve as a unit.
                                                    A
API




           Dependency



                        Implement
Circular
                          ation

             ...
API Dependency

 Component A has an API dependency on component B,
 if a type in B shows in the publicly accessible API su...
Implemenatin Dependency

  If a type in A uses a type in B in its implementation.
      Hard Dependencies (required to run...
Circular Dependency

 Component A depends on component B and
 Component B depends on component A (even indirectly).




  ...
Packaging Principle
  Package Cohesion Principle
       REP (Release Reuse Equivalency)
       CCP (Common Closure Princip...
A
Solution is Layering..




                         A
xDepend (NDepend)
        (ND




    NDepend - http://www.ndepend.com
WPF         XML




           
BCL       Reflection



                       A
Circular Dependency
                               GUI



            Comm
                                     Analysis

...
Creating a new packaging.
GUI



                                     Analysis
           Comm



Modem
                    Protocol               D...
Circular Dependency


     A                X



     B                Y
Adding new interface



       A                               X

                                           Y
           ...
Heavy Depedency




                  A
A
Heavy Dependencies and Testability
 // your API
 public class Tracer {
    MessageQueue mq = new MessageQueue(…);
    publ...
Inversion of Control
 // your better API
 public abstract class TraceListener {
    public abstract void Trace(string mess...
Dependency Injection
 // your customer’s program that is easier to test
 Tracer tracer = new Tracer(new FileListener());

...
// customer’s program that is even easier to test
Tracer tracer = container.Resolve<Tracer>();

public void ProcessOrder(O...
 DO balance advances with compatibility.




                                            A
Types of “Compatibility”


               Backward



               Cross-
               Cross-Version



              ...
Cross-Redist.
Cross-Redist.




                A
A
Define what’s a “breaking change”
This definition depends on the objective
   E.g. Enable portable code between Silverligh...
 AVOID duplication and overlap.




                                   A
Problem Space                      Show and Tell




PLoP – Capable, Productive and Satisfied Patterns for Productivity
  ...
When the new technology is “10x better”
Make sure you understand the impact on the ec
osystem
   What would happen if the ...
This is where quality happens




                                D
Is using your framework correctly like…




    Running across a desert?
A
 DO design APIs by
 first writing code samples for the main scenarios
   and then
 defining the object model to support t...
Code Samples




               D
Read File
   static void Main(string[] args)
    {
           StreamReader sr = File.OpenText(quot;MyFile.txtquot;);
     ...
Feedback (Read File)

 static void Main(string[] args)
 {
    foreach (string s in File.ReadAllLines(quot;MyFiles.textquot...
Object Model Listing




                       D
Framework Design Studio
Assembly Exploer




 Project -> Add -> Assembly

                                                ...
Framework Design Studio
Assembly Review Comment




                          D
Framework Design Studio
Compare API Versions




                          D
Framework Design Studio
Compare API Versions

                       Red is removed,
                       Green is added...
Framework Design Studio
Exporting to Microsoft Word




Tools -> Export to Document
 DO treat simplicity as a feature.




                                      D
Remove Requirements
Reuse Existing Concepts or APIs
Adjust Abstraction Level

Three Example (Evolving Frameworks)




    ...
 DO measure, measure, and measure!




                                      D
Specification Document: Qualities
 Performance Goals
    Baseline: What do is the best my API could do?
    Measure delta ...
 THE POWER OF SAMENESS




                          D
When you pick up your rental car….

 Push the seat all the way back
 Find an NPR station
 Find the exit

 Read the manual??
Oh, down to lock…
How to use a key…
Oh, you push the PRESS button…
Who actually
needs this data?
You know how to drive your car
All cars work basically the same way
Your rental car is a car
Therefore, you can drive your...
http://blogs.msdn.com/fxcop
The bits customers get, … or not




                                   V
Branches and Integrations

                                Main




           PU-staging         PU-staging   PU-staging
...
 AVOID integrating unfinished features.




                                           V
Functional Specification
Developer Design Specification
Test Plan
Threat Model
API review
Architectural Review
Dependency ...
 DO pay your debt.




                      V
Vision statement                  Feature complete          RTM
                                                       Rel...
Milestone Quality (MQ)
 Initiatives that are hard to do in regular milestones
 Large productivity and efficiency improveme...
 DO understand how organizational structure, culture, and decision making proc
   esses impact your product.
 AVOID pean...
Krzysztof Cwalina, Brad Abrams

Framework Design Guidelines:
Conventions, Idioms, and Patterns for Reusable .NET Libraries...
Douglas C. Schmidt (PLoP Editor, POSA 2, 4 Writter)

JAWS: An Application Framework for High Performance Web System
http:/...
Robert C. Martin
         Principles of Package Architecture (Design Principles and Design Patterns)

         http://www....
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-동일조건변경허락 2.0
                 대한민국 라이센스에 따라 이용하실 수 있습니다.
This work is licensed under Creat...
Framework Engineering_Final
Framework Engineering_Final
Upcoming SlideShare
Loading in …5
×

Framework Engineering_Final

2,367 views

Published on

Published in: Technology
  • Be the first to comment

Framework Engineering_Final

  1. 1. http://www.arload.net
  2. 2. Framework is ..
  3. 3. Framework is… is…
  4. 4. Douglas C. Schmidt Says.. Frameworks define “semi-complete” application “semi- that embody domain-specific object structures and functionality. domain-
  5. 5. Libraries is.. Application Block DATABASE ADTs App SpecificInvocations MATH NETWORKING Logic GRAPHICS GUI Event Loop Singleton Strategy Selections Reactor Adapter OO Design State Active Object Design Pattern Class Library Component Architecture
  6. 6. But Framework is .. Active Object State NETWORKING GUI MATH Reactor Invocations App Specific Logic Event Callbacks Loop ADTs Singleton Adapter DATABASE GRAPHICS Application Framework Component Architecture
  7. 7. Why Do You Need Framework? Avoid Duplication Productivity
  8. 8. Welcome to My Framework Journey!
  9. 9. “Framework Engineering”, TechED 2007 Europe “Framework Design Guidelines” , Addison Wesley Krzysztof Cwalina Program Manager on .NET Framework Team
  10. 10. 5 Topics.. Development Organization Design Planning Architecture O P A D V
  11. 11. The most powerful design tool O
  12. 12. Project Management Triangle Scope Cost Time O
  13. 13. Organization Project Management Triangle O
  14. 14.  DO understand how organizational structure, culture, and decision making processes impa ct your product. O
  15. 15. Conway's law If you have 4 groups working on a compiler, you’ll get a 4-pass compiler. O
  16. 16. Organization Software Structure Structure O
  17. 17. Conway's Clean State Approach • Define the business mission 1 • Learn the business process from business owners 2 • Re-engineer these process to fit the mission 3 • Structure the IT organization to support the reengine 4 ered business processes. O
  18. 18. Your Company Culture Is .. Voluntary ?? O
  19. 19. Your Company Culture Is .. Familial ?? O
  20. 20. Peremptory O
  21. 21. Organizational Influences Size of Organization Simple Design Consistency Design Focus on 80/20 Rules Small Team O
  22. 22. Organizational Influences Size of Organization Powerful Design Lack Consistency Remove Requirements Large Team O
  23. 23. Organizational Influences Organization’s Culture/Biases Customer-Focused End-2-End Scenarios O
  24. 24. Organizational Influences Organization’s Culture/Biases Technology-Focused Long Lasting Architecture O
  25. 25. Decision Making Process is.. O
  26. 26. Ensuring we are building the right thing P
  27. 27. P
  28. 28. Peanut Butter Skyscrapers Focus: features Focus: scenarios Results: stability, Results: Excitement, incremental breakthroughs, but improvements, not beware of leaving great end-to-end end-to- existing customers scenarios behind P
  29. 29. Moderation (中庸) (中庸) MileStone = Scenarios + Feature Vision statement Feature complete RTM Release Planning M1 M2 Testing Technology Preview Beta 1 Beta 2 RC1
  30. 30. Ensuring the long term health of the framework A
  31. 31. Right Way?? Choose right types. A
  32. 32. Taxonomy of Types Libraries , Primitives, Abstractions A
  33. 33. Primitives Very little policy (behavior design decisions) Stable design Commonly appear in publicly accessible APIs Almost impossible to evolve/change design; any design changes have huge breaking change impact on other APIs Example: Int32, String A
  34. 34. Libraries Definition: Libraries are types that are not passed between com ponents Examples EventLog, Debug, Easy to Evolve Leave old in, add new one Beware of duplication! A
  35. 35. Abstractions Definition: Abstractions are interfaces or classes with unsealed member s that are passed between components. Examples Stream, IComponent Hard to Evolve Unfortunately, pressure to evolve A
  36. 36. Primitive Oriented Design A.K.A. “Handle based design” (functional) Great evolvability, poor usability (sometimes) Low level stable primitives + high level reusable components with limited dep endencies other than to the primitives E.g. Type.GetType(object) – works, but not as convenient as Object.GetType A
  37. 37. for primitive.. C# 3.0 New Feature namespace MyCompany.StringManipulation { public static class StringExtensions{ public static bool IsNullOrEmpty(this string s){ return String.IsNullOrEmpty(s); } } } … using MyCompany.StringManipulation; string message= “hello world”; if(message.IsNullOrEmpty()){ Console.WriteLine(“EMPTY”); }
  38. 38. Component Oriented Design Rich APIs with lots of features, thus with lots of dependencies Great usability, poor evolvability Good for higher level components, not for the core of a platform A
  39. 39.  DO Manage Dependencies.. A
  40. 40. Component is .. Lego, Plug ?? A
  41. 41. .. a set of types that ship and evolve as a unit. A
  42. 42. API Dependency Implement Circular ation A
  43. 43. API Dependency Component A has an API dependency on component B, if a type in B shows in the publicly accessible API surface of a type in A. This includes: Base types and implemented interfaces Generic parameter constraints Return types and parameters of members Applied attributes Nested types A
  44. 44. Implemenatin Dependency If a type in A uses a type in B in its implementation. Hard Dependencies (required to run) Soft Dependencies (optional) A
  45. 45. Circular Dependency Component A depends on component B and Component B depends on component A (even indirectly). A
  46. 46. Packaging Principle Package Cohesion Principle REP (Release Reuse Equivalency) CCP (Common Closure Principle) CRP (Common Reuse Principle) Package Coupling Principle ADP (Acyclic Dependencies Principle) SDP (Stable Dependencies Principle) SAP (Stable Abstraction Principle) Robert C. Martin, Principle of Package Architecture A http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
  47. 47. A
  48. 48. Solution is Layering.. A
  49. 49. xDepend (NDepend) (ND NDepend - http://www.ndepend.com
  50. 50. WPF  XML   BCL Reflection A
  51. 51. Circular Dependency GUI Comm Analysis Modem Protocol Database Control Comm Error A
  52. 52. Creating a new packaging.
  53. 53. GUI Analysis Comm Modem Protocol Database Control Comm Error Message Manager A
  54. 54. Circular Dependency A X B Y
  55. 55. Adding new interface A X Y <<interface>> B BY
  56. 56. Heavy Depedency A
  57. 57. A
  58. 58. Heavy Dependencies and Testability // your API public class Tracer { MessageQueue mq = new MessageQueue(…); public void Trace(string message){ mq.Send(message); } } // your customer’s program that is hard to test Tracer tracer = new Tracer(); public void ProcessOrder(Order order){ tracer.Trace(order.Id); … }
  59. 59. Inversion of Control // your better API public abstract class TraceListener { public abstract void Trace(string message); } public class Tracer { TraceListener listener; public Tracer(TraceListener listener){ this.listener = listener; } public void Trace(string message){ listener.Trace(message); } }
  60. 60. Dependency Injection // your customer’s program that is easier to test Tracer tracer = new Tracer(new FileListener()); public void ProcessOrder(Order order){ tracer.Trace(order.Id); … }
  61. 61. // customer’s program that is even easier to test Tracer tracer = container.Resolve<Tracer>(); public void ProcessOrder(Order order){ tracer.Trace(order.Id); … } Check out DI Containers (a.k.a. IoC Containers): autofac, Castle Windsor, PicoContainer.NET, Spring.NET, StructureMap, Unity, nInject and others. http://www.nInject.org
  62. 62.  DO balance advances with compatibility. A
  63. 63. Types of “Compatibility” Backward Cross- Cross-Version Forward A
  64. 64. Cross-Redist. Cross-Redist. A
  65. 65. A
  66. 66. Define what’s a “breaking change” This definition depends on the objective E.g. Enable portable code between Silverlight and . NET Framework E.g. Enable cross-version portability? For example, Silverlight interfaces cannot have l ess members than .NET interfaces, but concrete types can. A
  67. 67.  AVOID duplication and overlap. A
  68. 68. Problem Space Show and Tell PLoP – Capable, Productive and Satisfied Patterns for Productivity A http://hillside.net/plop/plop98/final_submissions/P54.pdf
  69. 69. When the new technology is “10x better” Make sure you understand the impact on the ec osystem What would happen if the BCL team added a new S tring? What’s the migration path for code using the ol d API? A
  70. 70. This is where quality happens D
  71. 71. Is using your framework correctly like… Running across a desert?
  72. 72. A
  73. 73.  DO design APIs by first writing code samples for the main scenarios and then defining the object model to support the code samples. D
  74. 74. Code Samples D
  75. 75. Read File static void Main(string[] args) { StreamReader sr = File.OpenText(quot;MyFile.txtquot;); string s = sr.ReadLine(); while (s != null) { s = sr.ReadLine(); Console.WriteLine(s); } } D
  76. 76. Feedback (Read File) static void Main(string[] args) { foreach (string s in File.ReadAllLines(quot;MyFiles.textquot;)) { Console.WriteLine(s); } } D
  77. 77. Object Model Listing D
  78. 78. Framework Design Studio Assembly Exploer Project -> Add -> Assembly D Download here - http://code.msdn.microsoft.com/fds
  79. 79. Framework Design Studio Assembly Review Comment D
  80. 80. Framework Design Studio Compare API Versions D
  81. 81. Framework Design Studio Compare API Versions Red is removed, Green is added, Grey means inherited. D
  82. 82. Framework Design Studio Exporting to Microsoft Word Tools -> Export to Document
  83. 83.  DO treat simplicity as a feature. D
  84. 84. Remove Requirements Reuse Existing Concepts or APIs Adjust Abstraction Level Three Example (Evolving Frameworks) D
  85. 85.  DO measure, measure, and measure! D
  86. 86. Specification Document: Qualities Performance Goals Baseline: What do is the best my API could do? Measure delta from the baseline Threat Models Threat: What is the worst that my component co uld do? Mitigate the threats Same for many other qualities you want your f ramework to have D
  87. 87.  THE POWER OF SAMENESS D
  88. 88. When you pick up your rental car…. Push the seat all the way back Find an NPR station Find the exit Read the manual??
  89. 89. Oh, down to lock…
  90. 90. How to use a key…
  91. 91. Oh, you push the PRESS button…
  92. 92. Who actually needs this data?
  93. 93. You know how to drive your car All cars work basically the same way Your rental car is a car Therefore, you can drive your rental car That is…
  94. 94. http://blogs.msdn.com/fxcop
  95. 95. The bits customers get, … or not V
  96. 96. Branches and Integrations Main PU-staging PU-staging PU-staging branch branch branch Feature Feature branch branch V
  97. 97.  AVOID integrating unfinished features. V
  98. 98. Functional Specification Developer Design Specification Test Plan Threat Model API review Architectural Review Dependency Management Static Analysis Code Coverage Testing (Unit and Integration Tests) 0 Bugs Performance V
  99. 99.  DO pay your debt. V
  100. 100. Vision statement Feature complete RTM Release Planning M1 M2 Testing Technology Preview Beta 1 Beta 2 RC1 Milestone Quality
  101. 101. Milestone Quality (MQ) Initiatives that are hard to do in regular milestones Large productivity and efficiency improvements Infrastructure changes For example, a new source control system Refactoring of fragile subsystems Internal implementation documentation Bugs backlog V
  102. 102.  DO understand how organizational structure, culture, and decision making proc esses impact your product.  AVOID peanut-butter in Scenario Based Application.  DO manage your dependencies.  DO balance advances with compatibility.  AVOID duplication and overlap.  DO design APIs by first writing code samples for the main scenarios and then d efining the object model to support the code samples.  DO treat simplicity as a feature.  DO measure, measure, and measure!  AVOID integrating unfinished features.  DO pay your debt.
  103. 103. Krzysztof Cwalina, Brad Abrams Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries http://channel9.msdn.com/pdc2008/PC58/ http://www.gotdotnet.com/team/fxcop
  104. 104. Douglas C. Schmidt (PLoP Editor, POSA 2, 4 Writter) JAWS: An Application Framework for High Performance Web System http://citeseer.ist.psu.edu/81775.html (En) http://www.devpia.com/net2/EvaCast/Lecture/?cu=view&r=11 (Kr) Ralph Johnson (GoF , Design Patterns) Evolving Frameworks http://st-www.cs.uiuc.edu/users/droberts/evolve.html (En) http://arload.wordpress.com/2008/09/15/evolvingframeworks/ (Kr)
  105. 105. Robert C. Martin Principles of Package Architecture (Design Principles and Design Patterns) http://www.objectmentor.com/resources/articles/Principles_and_Pattern s.pdf (En) http://www.devpia.com/net2/EvaCast/Lecture/?cu=view&r=108 (Kr) For Korean People.. Load to Architect http://www.arload.net EvaCast (Online Free Lecture) http://www.evacast.net
  106. 106. 이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-동일조건변경허락 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다. This work is licensed under Creative Commons Korea Attribution 2.0 License.

×