Class extensions 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 application or in a different one. They suffer from modularity issues if globally visible: Other applications using the same classes are then affected by the modifications. This paper presents a hierarchical approach for dynamically scoping class extensions in dynamically-typed, class-based programming languages supporting class nesting. Our mechanism allows programmers to define the scope of class extensions and to reuse class extensions in other programs. Class extensions can be scoped according to a nested class hierarchy or based on whether programmers regard a potentially affected class as a black box or not. Class extensions are organized in layers, where multiple layers targeting the same class can be active at the same time. Categories and Subject Descriptors D.3.3 [Programming Languages]: Language Constructs and Features K...