A Layer-based Approach to Hierarchical Dynamically-scoped Open Classes

Open classes are frequently used in programming languages such as Ruby and Smalltalk to add or change methods of a class that is defined in the same component or in a different one. They are typically used for bug fixing, multi-dimensional separation of concerns, or to modularly add new operations to an existing class. However, they suffer from modularity issues if globally visible: Other components using the same classes are then affected by their modifications. This work presents Extension Classes, a hierarchical approach for dynamically scoping such modifications in Ruby, built on top of ideas from Context-oriented Programming (COP). Our mechanism organizes modifications in classes and allows programmers to define their scope according to a class nesting hierarchy and based on whether programmers regard an affected class as a black box or not. Moreover, Extension Classes support modularizing modifications as mixins, such that they can be reused in other components.

[1]  Oscar Nierstrasz,et al.  Classboxes: controlling visibility of class extensions , 2005, Comput. Lang. Syst. Struct..

[2]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[3]  Wakana Takeshita Method shells: controlling a scope of destructive class extensions by context switches , 2013, AOSD.

[4]  Harold Ossher,et al.  Hyper/J/sup TM/: multi-dimensional separation of concerns for Java/sup TM/ , 2000, Proceedings of the 2000 International Conference on Software Engineering. ICSE 2000 the New Millennium.

[5]  Hidehiko Masuhara,et al.  Matriona: class nesting with parameterization in Squeak/Smalltalk , 2016, MODULARITY.

[6]  Andry Rakotonirainy,et al.  Context-oriented programming , 2003, MobiDe '03.

[7]  Shigeru Chiba,et al.  Method Shells: Avoiding Conflicts on Destructive Class Extensions by Implicit Context Switches , 2013, SC@STAF.

[8]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[9]  Robert Hirschfeld,et al.  Declarative Layer Composition with The JCop Programming Language , 2013, J. Object Technol..

[10]  Hidehiko Masuhara,et al.  Hierarchical layer-based class extensions in Squeak/Smalltalk , 2016, MODULARITY.

[11]  Stanley M. Sutton,et al.  Hyper/J™: multi-dimensional separation of concerns for Java™ , 2001, ICSE '02.

[12]  Gary T. Leavens,et al.  MultiJava: modular open classes and symmetric multiple dispatch for Java , 2000, OOPSLA '00.

[13]  Michael Haupt,et al.  An Introduction to Context-Oriented Programming with ContextS , 2007, GTTSE.

[14]  Robert Hirschfeld,et al.  An open implementation for context-oriented layer composition in ContextJS , 2011, Sci. Comput. Program..

[15]  Oscar Nierstrasz,et al.  Traits: Composable Units of Behaviour , 2002, ECOOP.

[16]  Stanley M. Sutton,et al.  N degrees of separation: multi-dimensional separation of concerns , 1999, Proceedings of the 1999 International Conference on Software Engineering (IEEE Cat. No.99CB37002).

[17]  Sebastian Günther,et al.  Metaprogramming in Ruby: a pattern catalog , 2010, PLOP '10.

[18]  Alexandre Bergel,et al.  Classboxes: A Minimal Module Model Supporting Local Rebinding , 2003, JMLC.

[19]  Oscar Nierstrasz,et al.  Classbox/J: controlling the scope of change in Java , 2005, OOPSLA '05.

[20]  Oscar Nierstrasz,et al.  Squeak by Example , 2009 .

[21]  Oscar Nierstrasz,et al.  Classboxes : Controlling Visibility of Class Extensions c , 2010 .

[22]  Harold Ossher,et al.  Hyper/J/spl trade/: multi-dimensional separation of concerns for Java/spl trade/ , 2002, Proceedings of the 24th International Conference on Software Engineering. ICSE 2002.

[23]  William R. Cook,et al.  Mixin-based inheritance , 1990, OOPSLA/ECOOP '90.

[24]  Michael Haupt,et al.  A comparison of context-oriented programming languages , 2009, COP@ECOOP.

[25]  Shigeru Chiba,et al.  Method shelters: avoiding conflicts among class extensions caused by local rebinding , 2012, AOSD '12.

[26]  Hidehiko Masuhara,et al.  Type-Safe Layer-Introduced Base Functions with Imperative Layer Activation , 2015, COP@ECOOP.

[27]  Martin Odersky,et al.  Type classes as objects and implicits , 2010, OOPSLA.

[28]  Todd D. Millstein,et al.  Statically scoped object adaptation with expanders , 2006, OOPSLA '06.