Abstract:
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.
Reference:
A Layer-based Approach to Hierarchical Dynamically-scoped Open Classes (Matthias Springer, Hidehiko Masuhara and Robert Hirschfeld), In Journal of Information Processing, volume 25, 2017. (Also published in IPSJ Transactions on Programming.)
Bibtex Entry:
@article{springer2017jip,
author = {Matthias Springer and Hidehiko Masuhara and Robert Hirschfeld},
title = {A Layer-based Approach to Hierarchical Dynamically-scoped Open Classes},
pdf = {jip2017.pdf},
journal = {Journal of Information Processing},
year = 2017,
volume = {25},
optnumber = { },
pages = {296-307},
month = mar,
doi = {10.2197/ipsjjip.25.296},
annote = {Revised version of \cite{springer2016pro}, received 2016-07-08, accepted 2016-10-26},
note = {Also published in IPSJ Transactions on Programming.},
keywords = {Squeak, Smalltalk},
abstract = {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.}
}