COP’12, 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 www.hpi.uni-potsdam.de/swa 2012-06-11
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 Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 2
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 Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 3
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming 2. Self-supporting Development Environments • Examples: Smalltalk, Self, Emacs, Squeak, and Lively Kernel Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 4
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 Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 5
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 Steinert et.al 2012 Continuous Versioning Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 6
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 objects under construction Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 7
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Event Counter Example Definition of a core object: EventCounter = { � � n: 0, � � count: function(evt) { � � � this.n = this.n + 1; � � } � } �� Directly changing the object at runtime: EventCounter.count = function(evt) { � � alert("evt: " + evt); � � this.n = this.n + 1; � } � → If tools use this count method, the system becomes unusable Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 8
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 … ) Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 9
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Organizing Changes as Layers Layer Definition cop.create("DevLayer").refineObject(EventCounter, { � � count: function(evt) { � � � alert("evt: " + evt); � cop.proceed(evt); � � � this.n = this.n + 1; � � } � }) � Refining Classes (syntactic sugar in JavaScript) cop.create("DevLayer").refineClass(TextMorph, { /* … */ } ) � Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 10
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Scoping Changes – Layer Activation • Allows for: scoping behavioral adaptations – Global DevLayer.beGlobal(); � – Dynamic extent cop.withLayers([DevLayer], function() { � � /* … */ � }) � – Instance-specific and structural scoping debugArea.setWithLayers([DevLayer]) � Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 11
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Merging Changes back into the Base System Code from core system Development layer EventCounter = { � cop.create("DevLayer").refineObject(EventCounter, � count: function(evt) { � n: 0, � if (evt.type === 'mousedown') { � count: function(evt) { � � this.n = this.n + 1; � this.n = this.n + 1; � }; � } � } � cop.proceed(evt); � } � }) � Manual merge New version of the core system EventCounter = { � n: 0, � count: function(evt) { � if (evt.type === 'mousedown') { � this.n = this.n + 1; � }; � } � } � Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 12
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming 4. Examples in Webwerkstatt – A Web-based Development Environment Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 14
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 http://lively-kernel.org/webwerkstatt Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 15
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Example 1: Visualizing Events (structural scoping) Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 16
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Example 1: Visualizing Events Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 17
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Example 2: Text Coloring this.setWithLayers([...]) � TextColorLayer.beGlobal() � Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 18
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Example 3: Developing Autocompletion $morph('DevArea').setWithLayers([WordCompletionLayer]); � Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 19
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming 5. Proposed Tool Support: Capturing Changes Explicit COP usage C Capturing with tools Capturing with class syntax A B workspace workspace Class Browser X X X DevLayerA DevLayerA Layer Name Layer Name cop.createLayer("DevLayerA") Foo.addMethods({ bar .refineClass(Foo, { Foo bar2 bar: function() { Foo2 bar: function() { bar3 // … // … Class Names Method Names }, }, // … // … function() { }) }) // … } COP Layer Definition Syntax Class Syntax Method Body Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 20
Scoping Changes in Self-supporting Development Environments using Context-oriented Programming Interactive Layer Composition Global | ObjectA | ... select scope DevLayerA (de-)activate layers DevLayerB DevLayerC … Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 21
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 Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 22
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 • … http://lively-kernel.org/webwerkstatt Software Architecture Group (www.hpi.uni-potsdam.de/swa) 2006-2012 23
COP’12, 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 www.hpi.uni-potsdam.de/swa 2012-06-11
Recommend
More recommend