Connecting Object Constraints with Context-oriented Programming

Stefan Lehmann, Tim Felgentreff, Robert Hirschfeld
2015 Proceedings of the 7th International Workshop on Context-Oriented Programming - COP'15  
Context-oriented Programming extends object-oriented languages with a mechanism to dynamically adapt behavior. Object Constraint Programming orthogonally extends object-oriented run-times by integrating constraints, including support for constraints over mutable state, object identity, and the results of message sends. Using these two language extensions in conjunctions offers interesting opportunities. In this paper, we report on new mechanisms involving layers and constraints that evolved
more » ... our experiences with combining Babelsberg/JS, an Object Constraint Language, and ContextJS, an implementation of Contextoriented Programming in JavaScript. First, our experience shows that it is desirable to dynamically adapt declarative constraints, which offer an orthogonal mechanism to the definition of imperative behavior, likewise at runtime. In this work, we show an extension to ContextJS to scope activation or refinement of constraints dynamically using layers. Second, ContextJS already provides different activation mechanisms for layers, including dynamically or structurally scoped, or globally through system generated events. Constraints provide an activation mechanism based on arbitrary boolean expressions changing their value, allowing for interesting applications of behavioral adaption based on certain conditions.
doi:10.1145/2786545.2786549 dblp:conf/ecoop/LehmannFH15 fatcat:w2wvsblrzjfvfabarpgz6m3rzi