Scoping Changes in Self-supporting Development Environments using - - PowerPoint PPT Presentation
Scoping Changes in Self-supporting Development Environments using - - PowerPoint PPT Presentation
COP12, June 11, 2012 Beijing, China Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Jens Lincke and Robert Hirschfeld Software Architecture Group Hasso-Plattner-Institut Potsdam
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Outline
- 1. Introduction
- 2. Self-supporting Development Environments
- 3. Using Scoped Behavioral Adaptations for Evolving
Self-supporting Development Environments
- 4. Examples in Webwerkstatt
– A Web-based Development Environment
- 5. Proposed Tool Support: Capturing Changes
- 6. Conclusion
2
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
- 1. Introduction
- Interactive development in self-supporting systems
– Direct and explorative development workflow – Immediate feedback loops
- Problem
– Changes to core behavior can lead to accidentally breaking the environment
- Separating the tools from the objects they work on
– Avoid self-referentiality at the expense of interactivity
- Approach
– Use context- oriented programming (COP) to separate tools from objects under development while keeping them in the same environment
3
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
- 2. Self-supporting Development Environments
- Examples: Smalltalk, Self, Emacs, Squeak, and Lively Kernel
4
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Separate Runtime Environments
- Development tools run in a separate environment
– Work on static code – Bootstrapped by external code
- Inter-process communication
- vs. direct access to objects
5
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Separate Meta-Objects
- Tools access objects directly
- Core parts of the system are adaptable
- Objects are tightly coupled to a version of a class
→ New behavior only available for new instances
6
Steinert et.al 2012 Continuous Versioning
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
- 3. Using Scoped Behavioral Adaptations for Evolving
Self-supporting Development Environments
- Use COP layers to adapt core classes
and methods at run-time
- Changes affect only behavior of
- bjects under construction
7
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Event Counter Example
8
EventCounter = { n: 0, count: function(evt) {
- this.n = this.n + 1;
} }
- EventCounter.count = function(evt) {
alert("evt: " + evt); this.n = this.n + 1; }
Definition of a core object: Directly changing the object at runtime: → If tools use this count method, the system becomes unusable
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
ContextJS
- JavaScript language extension for
Context-oriented Programming (COP)
- Behavioral variations for JavaScript objects
- Implemented as a library
– Method Wrappers for layer-aware method dispatch – Partial methods
- Open implementation for layer composition
(activeLayers…)
9
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Organizing Changes as Layers
10
cop.create("DevLayer").refineObject(EventCounter, { count: function(evt) {
- alert("evt: " + evt);
- this.n = this.n + 1;
} })
Layer Definition Refining Classes (syntactic sugar in JavaScript)
cop.create("DevLayer").refineClass(TextMorph, { /* … */ } ) cop.proceed(evt);
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Scoping Changes – Layer Activation
- Allows for: scoping behavioral adaptations
– Global – Dynamic extent – Instance-specific and structural scoping
11
cop.withLayers([DevLayer], function() { /* … */ }) DevLayer.beGlobal(); debugArea.setWithLayers([DevLayer])
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Merging Changes back into the Base System
12
cop.create("DevLayer").refineObject(EventCounter, count: function(evt) { if (evt.type === 'mousedown') { this.n = this.n + 1; }; } })
EventCounter = { n: 0, count: function(evt) { if (evt.type === 'mousedown') { this.n = this.n + 1; }; } } EventCounter = { n: 0, count: function(evt) { this.n = this.n + 1; } }
Code from core system Development layer New version of the core system Manual merge
cop.proceed(evt);
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
- 4. Examples in Webwerkstatt
– A Web-based Development Environment
14
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Lively Webwerkstatt
- Lively Kernel-based Wiki
- Web-based authoring environment
- Core idea
– Allow authors to not only change their content, but to also shape their tools as they are using them
→ Share ideas and tools directly → Self-sustaining Lively Kernel development
15
http://lively-kernel.org/webwerkstatt
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Example 1: Visualizing Events (structural scoping)
16
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Example 1: Visualizing Events
17
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Example 2: Text Coloring
18
this.setWithLayers([...]) TextColorLayer.beGlobal()
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Example 3: Developing Autocompletion
19
$morph('DevArea').setWithLayers([WordCompletionLayer]);
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
- 5. Proposed Tool Support: Capturing Changes
20
A
Class Browser
X
workspace
X
workspace
X
cop.createLayer("DevLayerA") .refineClass(Foo, { bar: function() { // … }, // … }) Foo.addMethods({ bar: function() { // … }, // … })
DevLayerA
function() { // … } Foo Foo2 bar bar2 bar3
DevLayerA B C
Class Syntax COP Layer Definition Syntax Layer Name Layer Name Class Names Method Names Method Body
Explicit COP usage Capturing with class syntax Capturing with tools
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Interactive Layer Composition
21
DevLayerA DevLayerB DevLayerC
…
Global | ObjectA | ... select scope (de-)activate layers
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
- 6. Conclusion
- Evolution of tools in self-supporting development
environments can be direct and interactive
- Changing core parts can accidentally break the
system
- We applied COP to self-supporting
development environments
– Organize changes into layers – Scope changes to objects of interest
→ To work safely on new features
22
Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 Scoping Changes in Self-supporting Development Environments using Context-oriented Programming
Future Work
- Automatic and implicit creation of layered methods
- Merging support of layers with the base system
- …
23