evolution-enabled application-programming interfaces ralf lämmel data programmability team...
TRANSCRIPT
![Page 1: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/1.jpg)
Evolution-enabled application-programming interfaces
Ralf LämmelData Programmability Team
Microsoft, Redmond
![Page 2: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/2.jpg)
API asbestos and its remedy
Source of the term “software asbestos”:Klusener, Lämmel, Verhoef:“Architectural modifications to deployed software”,2005, Science of Computer Programming
C++ code for window creation in pre-.NET
HWND hwndMain = CreateWindowEx( 0,"MainWinClass", "Main Window",WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,CW_USEDDEFAULT, CW_USEDEFAULT,
CW_USEDDEFAULT, CW_USEDEFAULT,(HWND)NULL,(HMENU)NULL, hInstance, NULL);
ShowWindow(hwndMain, SW_SHOWDEFAULT);UpdateWindow(hwndMain);
.NET version
Form form = new Form();form.Text = "Main Window";form.Show();
![Page 3: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/3.jpg)
Table of contents
• Call to arms
• More examples
• Categorization
• Techniques
• Show stoppers
![Page 4: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/4.jpg)
Evolutionary API transformationsWhy is that a worthy research
challenge?
• Improve quality of APIs.• Support effective obsoletion.• Decrease platform complexity.• Orthogonal to model-driven xyz.• Improve productivity of developers.
![Page 5: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/5.jpg)
API evolution samples
• CodeDom: program generation
• Xml.Schema: XML schema processing
• DOM vs. XML binding: API-fication
![Page 6: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/6.jpg)
API asbestos:My first .NET program
Sigh!Main.cs(…,…): warning CS0618:
'System.CodeDom.Compiler.CodeDomProvider.CreateGenerator()‘ is obsolete.
Use CodeDom API for program generation CodeCompileUnit compileUnit = new CodeCompileUnit(); // ... build some cool code objects CSharpCodeProvider provider = new CSharpCodeProvider(); ICodeGenerator gen = provider.CreateGenerator(); IndentedTextWriter tw = new … // create a text writer gen.GenerateCodeFromCompileUnit(compileUnit, tw,
new CodeGeneratorOptions());
![Page 7: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/7.jpg)
Typical developer support
![Page 8: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/8.jpg)
CodeCompileUnit compileUnit = new CodeCompileUnit(); // ... build some cool code objects CSharpCodeProvider provider = new CSharpCodeProvider(); // ICodeGenerator gen = provider.CreateGenerator(); IndentedTextWriter tw = new … // create a text writer provider.GenerateCodeFromCompileUnit(compileUnit, tw, new CodeGeneratorOptions());
Elimination of the obsolete pattern
That is, we get rid of the extra generator object, anddirectly use the Generate… method of the provider object.
![Page 9: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/9.jpg)
CodeCompileUnit compileUnit = new CodeCompileUnit(); // ... build some cool code objects CSharpCodeProvider provider = new CSharpCodeProvider(); // ICodeGenerator gen = provider.CreateGenerator(); IndentedTextWriter tw = new … // create a text writer provider.GenerateCodeFromCompileUnit(compileUnit, tw, new CodeGeneratorOptions());
How to …?
• Find offending “Create” calls.• Get a handle on factory (provider).• Find all uses of created generator.• Setup provider itself as generator.
![Page 10: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/10.jpg)
More API asbestos:My second .NET program
Sigh!
Main.cs(…,…): warning CS0618: 'System.Xml.Schema.XmlSchema.Compile(System.Xml. Schema.ValidationEventHandler)' is obsolete: 'Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation.'
Use Schema object model (SOM) for schema processing
XmlSchema schema = new XmlSchema(); // … do something cool with the schema schema.Compile(
new ValidationEventHandler(ValidationCallbackOne));
![Page 11: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/11.jpg)
An attempted modernization
XmlSchema schema = new XmlSchema(); // … do something cool with the schema XmlSchemaSet set = new XmlSchemaSet(); set.Add(schema); set.ValidationEventHandler +=
new ValidationEventHandler(ValidationCallbackOne);
// schema.Compile( // new ValidationEventHandler( // ValidationCallbackOne)); set.Compile();
How to get this right? Is the above guess correct anyway?
![Page 12: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/12.jpg)
Deprecated classes, methods, fieldsin Java world
Source: Henkel & Diwan: “CatchUp! Capturing and Replaying Refactorings to Support API Evolution”International Conference on Software Engineering, 2005
![Page 13: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/13.jpg)
Burdens implied by API evolution
• API producer• Upward compatibility• Extending maintenance• Investments
• Tools• Processes• Documentation
• API consumer• Re-engineering for eradication• Complexity due to multiple versions
![Page 14: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/14.jpg)
An example for API-fication or translation
• Given: a C# program that accesses XML business data through DOM.
• Wanted: a converted C# program that uses XML binding instead.
• Needed: (This is the naïve version.)• The relevant XML schema(s)• An XML binding technology• A dedicated C# program transformation• Potentially: IDE component
![Page 15: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/15.jpg)
Untyped (DOM-based) XML functionality
![Page 16: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/16.jpg)
Typeful XML functionality
![Page 17: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/17.jpg)
Kinds of API evolution
• Refactoring• Service introduction• Service extension• Service elimination• Service restriction• API-fication• API translation
Example: Replacement of DOM by XML binding
• Refactoring: Prepare the introduction of XML binding technology• Translation: Replace DOM patterns by schema-derived object model• Extension: Inject additional validation functionality into the application
Compare to kinds of grammar adaptation:Lämmel: “Grammar Adaptation”,Formal Methods Europe, 2001
![Page 18: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/18.jpg)
• Weak and strong obsoletion• Provision of facades• Provision of parallel versions• Migration guides, strategies, wizards• Byte-code transformations• Source-code transformations
Techniques for API evolution
![Page 19: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/19.jpg)
What about refactoring?
![Page 20: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/20.jpg)
Record refactorings on the API developer’s site
Replay refactorings on the API user’s site
Source: Henkel & Diwan: “CatchUp! Capturing and Replaying Refactorings to Support API Evolution”International Conference on Software Engineering, 2005
![Page 21: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/21.jpg)
We cannot expect in general:• a refactoring suite to be sufficiently expressive,• refactoring to be practical for API developer,• a change scenario to be semantics-preserving.
So what?
![Page 22: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/22.jpg)
Musts• Source-code transformation• Source-code model with high fidelity• Type analysis, simple DFA/CFA• Test harness for system under transformation• Simple feedback mechanisms
Shoulds• More advanced user interaction• More advanced DFA/CFA/effect analyses• API protocols based on temporal logic• Security models and other constraints• Coverage of multiple (“all”) languages• Story for 80/20 conversions
The envisaged transformation framework
![Page 23: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/23.jpg)
Potential show stoppers
• Language issues
• Incompleteness issues
• Legal issues
![Page 24: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/24.jpg)
Language issues
• Reflection
• Threads
• Side effects
• Third party frameworks
• Multitude of languages
![Page 25: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/25.jpg)
Incompleteness issues
• API producer can’t convert
• API consumer won’t convert
![Page 26: Evolution-enabled application-programming interfaces Ralf Lämmel Data Programmability Team Microsoft, Redmond](https://reader034.vdocument.in/reader034/viewer/2022042718/56649e4f5503460f94b46f8d/html5/thumbnails/26.jpg)
Legal issues
• How to sell 80/20 solutions?• Can we promise correctness?• How to prove correctness to client?• Development may rely on client code?• Support may rely on client code?