Classboxes: A Minimal Module Model
  Supporting Local Class Extension

   Alexandre Bergel, Stéphane Ducasse,
             and Roel Wuyts
       Software Composition Group
      University of Bern (Switzerland)
           bergel@iam.unibe.ch
Outline
1.   Class extension and Package
2.   Supporting Unanticipated Changes
3.   The Classbox Model
4.   Implementation
5.   Conclusion
6.   Future Work


                                        1
Class Extension

• Languages such as CLOS or Smalltalk provide a
  mechanism of Class Extension

• A Class Extension is the ability to add or redefine
  methods on a class after its creation



                                                2
Class Extension: A powerful Mechanism
Visitor Example:
BlackPackage
              Opr



    Add             Mult



                                   3
Class Extension: A powerful Mechanism
Visitor Example:
BlackPackage                         BluePackage
                  Opr
           acceptVisitor()               Visitor
                                         doAdd()
     Add                Mult             doMult()
acceptVisitor()    acceptVisitor()


                                                    4
Subclassing does not Solve it

            Opr                        Parser
                                       parse()
   Add            Times
                                    …
                                    Add.new()
    Add’             Times’         …
acceptVisitor()   acceptVisitor()

Subclasses are not referenced by the tree constructor
                                                 5
In Smalltalk
• Class extensions are global
• Any application can modify any class in the system

Consequences
   – Conflicts may arise (e.g., two applications may add the
     same method)
   – Robustness aspect (e.g., an application may redefine a
     critical method)

                                                     6
Supporting Unanticipated Changes:
                Adaptation
• Java, Modula-3,…have package/modules but no Class
  Extension
• Smalltalk has Class Extension but no package/module

      fi Class Extension + Module ?

• How to control class extensions?
• How to apply a set of unanticipated changes without
  breaking existing clients?

                                                    7
Classbox Model Definition
• The Classbox Model is a minimal module model
  supporting local class extension
• A Classbox
   –   Is a unit of scoping (i.e., it acts as a namespace)
   –   Can define classes
   –   Can import class definitions from other classboxes
   –   Can define methods on classes in the scope: class extensions
• Classes and methods always belong to exactly one
  classbox
• Visibility of each element in a classbox is bound to this
  classbox

                                                             8
Classbox Model: Avoiding Conflict
  By having class           TextClassbox                   import
  extensions local to a
                            String
  classbox, conflicts are
  avoided                                  URLClassbox
                                                URL
WWWClassbox
                  WWWURL                          String
                                                  asUrl
                  String
WWWURL.new()      asUrl
…                                          URL.new()
                                           …

                                                       9
Classbox Model: Import and Visibility
 Extended classes can be          TextClassbox              import
 used by classboxes
                                   String
 through the import
 relationship                                    URLClassbox
                                                   URL
RedClassbox
                                                   String
…                                                  asUrl
url = “http://www.iam.unibe.ch/~scg”.asUrl()




                                                     10
Classbox Model: Classbox as a Sandbox
All the changes are local, so       CollectionClassbox           import
redefinition of a critical method
is limited to the Classbox          OrderedCollection
providing the extension              do()

                                                 GreenClassbox
                                              OrderedCollection
                                               do()
                      aCollection.do(…)
                                                        C
                  C.new().foo()                 foo()

                                                            11
Classbox Model: Flattening Property
Any expression executed in a       CollectionClassbox         import
classbox will be evaluated as if   OrderedCollection
the whole classbox graph were       do()
collapsed to a single classbox.     copy() 2

                                                GreenClassbox
      self.do(element.copy())                OrderedCollection
                                              do() 3
                     aCollection.copy(…)
                                                     C
                  C.new().bar()                bar() 1

                                                         12
From within the Green Classbox




                                       GreenClassbox
self.do(element.copy())             OrderedCollection
                                     do() 3
                                     copy() 2
              aCollection.copy(…)
                                           C
          C.new().bar()              bar() 1

                                             13
Implementation
• Implemented in Squeak, an open-source Smalltalk
• To avoid excessive memory costs:
  – modify the VM
• New method lookup taking some extra parameters
  into account such as:
  – Original classbox (referring the classbox where the
    initial expression is executed)
  – Collection of all the traversed classboxes
                                                   14
Lookup: Imports before Inheritance

CollectionClassbox      ImprovedClassbox     PinkClassbox
 OrderedCollection       OrderedCollection            Pink
 do()                    do()                 foo()
 copy()
                                             aSortedCollection.copy()

 SortedCollection        SortedCollection    SortedCollection



                                              Pink.new().foo()
Lookup of the copy() method
                                                        15
Lookup: Imports before Inheritance

CollectionClassbox      ImprovedClassbox     PinkClassbox
 OrderedCollection       OrderedCollection            Pink
 do()                    do()                 foo()
 copy() 6                         5                     4
                                             aSortedCollection.copy()

 SortedCollection        SortedCollection    SortedCollection
          3                       2                     1
                                              Pink.new().foo()
Lookup of the copy() method
                                                        16
Lookup: Imports before Inheritance
The copy() method invokes do() one
CollectionClassbox       ImprovedClassbox           PinkClassbox
 OrderedCollection         OrderedCollection        PinkClass
 do()                      do()                     foo()
 copy()                              5                         4
                                                    aSortedCollection.copy()

 SortedCollection          SortedCollection         SortedCollection
           3                         2                         1

  Without any drastic optimization, a system is 60% slower
                                                               17
Conclusion
• Definition of a module system for controlling class
  extensions:
   – Method addition and replacement are only visible in the
     module that defines them
   – Control the visibility
   – Support for unanticipated evolution
• New method lookup
   – This has a price: slow performance with the current
     implementation

                                                    18
Future Work
• Allow aliasing, when importing

• Refined visibility control (allowing an extension to be
  global: evolution of a classbox)

• Add multiple Classbox interfaces (clients may see a
  classbox under different views)

• Formalization to specify the flattening property

                                                       19
Contact Information


• Alexandre Bergel (bergel@iam.unibe.ch)

• Website:
  – http://www.iam.unibe.ch/~scg/Research/Classboxes/index.html




                                                        20

More Related Content

PDF
The Ring programming language version 1.6 book - Part 37 of 189
PDF
Looking Ahead to Tcl 8.6
PPTX
TclOO: Past Present Future
PPTX
Adventures in TclOO
PDF
Tcl2012 8.6 Changes
PDF
Scala for Java Developers - Intro
PPTX
SQL Server Select Topics
PPTX
Introduction to Haskell: 2011-04-13
The Ring programming language version 1.6 book - Part 37 of 189
Looking Ahead to Tcl 8.6
TclOO: Past Present Future
Adventures in TclOO
Tcl2012 8.6 Changes
Scala for Java Developers - Intro
SQL Server Select Topics
Introduction to Haskell: 2011-04-13

What's hot (20)

PPTX
Chapter ii(oop)
PDF
The Ring programming language version 1.4.1 book - Part 10 of 31
PPTX
PDF
Java OOP Programming language (Part 8) - Java Database JDBC
PDF
The Ring programming language version 1.4.1 book - Part 9 of 31
PDF
4 gouping object
PPT
Collections Framework
PPT
JDK1.7 features
PDF
Java OOP Programming language (Part 4) - Collection
PDF
The Ring programming language version 1.6 book - Part 36 of 189
PDF
The Ring programming language version 1.8 book - Part 39 of 202
PPTX
Python lec5
KEY
Clojure Intro
PDF
C h 04 oop_inheritance
PPTX
Python lec4
PDF
The Ring programming language version 1.7 book - Part 29 of 196
DOC
Inheritance
PDF
From Java to Parellel Clojure - Clojure South 2019
PPTX
XQuery Extensions
PDF
Javascript foundations: Classes and `this`
Chapter ii(oop)
The Ring programming language version 1.4.1 book - Part 10 of 31
Java OOP Programming language (Part 8) - Java Database JDBC
The Ring programming language version 1.4.1 book - Part 9 of 31
4 gouping object
Collections Framework
JDK1.7 features
Java OOP Programming language (Part 4) - Collection
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.8 book - Part 39 of 202
Python lec5
Clojure Intro
C h 04 oop_inheritance
Python lec4
The Ring programming language version 1.7 book - Part 29 of 196
Inheritance
From Java to Parellel Clojure - Clojure South 2019
XQuery Extensions
Javascript foundations: Classes and `this`
Ad

Similar to Classboxes (20)

PPT
Feltman collections
PDF
Scala oo
PDF
Spock: Test Well and Prosper
PDF
The Ring programming language version 1.2 book - Part 5 of 84
PPTX
Inheritance
PDF
Collections
PDF
Collections In Java
PDF
Collections in java
PDF
Python concurrency: libraries overview
PPTX
More topics on Java
PDF
A Scala tutorial
PPTX
Java Reflection Concept and Working
PPT
Software Design Patterns
PPT
Implementation of 'go-like' language constructions in scala [english version]
PDF
Chapter- 3 Inheritance and Polymorphism-1x4.pdf
PDF
Spock: A Highly Logical Way To Test
PPTX
Design patterns(red)
PPTX
Object-Oriented Programming with C#
PDF
The Ring programming language version 1.3 book - Part 84 of 88
PDF
Design patterns
Feltman collections
Scala oo
Spock: Test Well and Prosper
The Ring programming language version 1.2 book - Part 5 of 84
Inheritance
Collections
Collections In Java
Collections in java
Python concurrency: libraries overview
More topics on Java
A Scala tutorial
Java Reflection Concept and Working
Software Design Patterns
Implementation of 'go-like' language constructions in scala [english version]
Chapter- 3 Inheritance and Polymorphism-1x4.pdf
Spock: A Highly Logical Way To Test
Design patterns(red)
Object-Oriented Programming with C#
The Ring programming language version 1.3 book - Part 84 of 88
Design patterns
Ad

More from ESUG (20)

PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
PDF
Directing Generative AI for Pharo Documentation
PDF
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
PDF
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
PDF
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
PDF
Analysing Python Machine Learning Notebooks with Moose
PDF
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
PDF
Package-Aware Approach for Repository-Level Code Completion in Pharo
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
PDF
An Analysis of Inline Method Refactoring
PDF
Identification of unnecessary object allocations using static escape analysis
PDF
Control flow-sensitive optimizations In the Druid Meta-Compiler
PDF
Clean Blocks (IWST 2025, Gdansk, Poland)
PDF
Encoding for Objects Matters (IWST 2025)
PDF
Challenges of Transpiling Smalltalk to JavaScript
PDF
Immersive experiences: what Pharo users do!
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
PDF
Cavrois - an Organic Window Management (ESUG 2025)
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Micromaid: A simple Mermaid-like chart generator for Pharo
Directing Generative AI for Pharo Documentation
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
Analysing Python Machine Learning Notebooks with Moose
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
Package-Aware Approach for Repository-Level Code Completion in Pharo
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
An Analysis of Inline Method Refactoring
Identification of unnecessary object allocations using static escape analysis
Control flow-sensitive optimizations In the Druid Meta-Compiler
Clean Blocks (IWST 2025, Gdansk, Poland)
Encoding for Objects Matters (IWST 2025)
Challenges of Transpiling Smalltalk to JavaScript
Immersive experiences: what Pharo users do!
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
Cavrois - an Organic Window Management (ESUG 2025)

Recently uploaded (20)

PPTX
Configure Apache Mutual Authentication
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
Modernising the Digital Integration Hub
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
The various Industrial Revolutions .pptx
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPT
What is a Computer? Input Devices /output devices
PPTX
Chapter 5: Probability Theory and Statistics
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Configure Apache Mutual Authentication
OpenACC and Open Hackathons Monthly Highlights July 2025
sbt 2.0: go big (Scala Days 2025 edition)
Modernising the Digital Integration Hub
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
A review of recent deep learning applications in wood surface defect identifi...
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
The various Industrial Revolutions .pptx
Microsoft Excel 365/2024 Beginner's training
Abstractive summarization using multilingual text-to-text transfer transforme...
Flame analysis and combustion estimation using large language and vision assi...
Developing a website for English-speaking practice to English as a foreign la...
Module 1.ppt Iot fundamentals and Architecture
Convolutional neural network based encoder-decoder for efficient real-time ob...
A comparative study of natural language inference in Swahili using monolingua...
Final SEM Unit 1 for mit wpu at pune .pptx
What is a Computer? Input Devices /output devices
Chapter 5: Probability Theory and Statistics
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Credit Without Borders: AI and Financial Inclusion in Bangladesh

Classboxes

  • 1. Classboxes: A Minimal Module Model Supporting Local Class Extension Alexandre Bergel, Stéphane Ducasse, and Roel Wuyts Software Composition Group University of Bern (Switzerland) bergel@iam.unibe.ch
  • 2. Outline 1. Class extension and Package 2. Supporting Unanticipated Changes 3. The Classbox Model 4. Implementation 5. Conclusion 6. Future Work 1
  • 3. Class Extension • Languages such as CLOS or Smalltalk provide a mechanism of Class Extension • A Class Extension is the ability to add or redefine methods on a class after its creation 2
  • 4. Class Extension: A powerful Mechanism Visitor Example: BlackPackage Opr Add Mult 3
  • 5. Class Extension: A powerful Mechanism Visitor Example: BlackPackage BluePackage Opr acceptVisitor() Visitor doAdd() Add Mult doMult() acceptVisitor() acceptVisitor() 4
  • 6. Subclassing does not Solve it Opr Parser parse() Add Times … Add.new() Add’ Times’ … acceptVisitor() acceptVisitor() Subclasses are not referenced by the tree constructor 5
  • 7. In Smalltalk • Class extensions are global • Any application can modify any class in the system Consequences – Conflicts may arise (e.g., two applications may add the same method) – Robustness aspect (e.g., an application may redefine a critical method) 6
  • 8. Supporting Unanticipated Changes: Adaptation • Java, Modula-3,…have package/modules but no Class Extension • Smalltalk has Class Extension but no package/module fi Class Extension + Module ? • How to control class extensions? • How to apply a set of unanticipated changes without breaking existing clients? 7
  • 9. Classbox Model Definition • The Classbox Model is a minimal module model supporting local class extension • A Classbox – Is a unit of scoping (i.e., it acts as a namespace) – Can define classes – Can import class definitions from other classboxes – Can define methods on classes in the scope: class extensions • Classes and methods always belong to exactly one classbox • Visibility of each element in a classbox is bound to this classbox 8
  • 10. Classbox Model: Avoiding Conflict By having class TextClassbox import extensions local to a String classbox, conflicts are avoided URLClassbox URL WWWClassbox WWWURL String asUrl String WWWURL.new() asUrl … URL.new() … 9
  • 11. Classbox Model: Import and Visibility Extended classes can be TextClassbox import used by classboxes String through the import relationship URLClassbox URL RedClassbox String … asUrl url = “http://www.iam.unibe.ch/~scg”.asUrl() 10
  • 12. Classbox Model: Classbox as a Sandbox All the changes are local, so CollectionClassbox import redefinition of a critical method is limited to the Classbox OrderedCollection providing the extension do() GreenClassbox OrderedCollection do() aCollection.do(…) C C.new().foo() foo() 11
  • 13. Classbox Model: Flattening Property Any expression executed in a CollectionClassbox import classbox will be evaluated as if OrderedCollection the whole classbox graph were do() collapsed to a single classbox. copy() 2 GreenClassbox self.do(element.copy()) OrderedCollection do() 3 aCollection.copy(…) C C.new().bar() bar() 1 12
  • 14. From within the Green Classbox GreenClassbox self.do(element.copy()) OrderedCollection do() 3 copy() 2 aCollection.copy(…) C C.new().bar() bar() 1 13
  • 15. Implementation • Implemented in Squeak, an open-source Smalltalk • To avoid excessive memory costs: – modify the VM • New method lookup taking some extra parameters into account such as: – Original classbox (referring the classbox where the initial expression is executed) – Collection of all the traversed classboxes 14
  • 16. Lookup: Imports before Inheritance CollectionClassbox ImprovedClassbox PinkClassbox OrderedCollection OrderedCollection Pink do() do() foo() copy() aSortedCollection.copy() SortedCollection SortedCollection SortedCollection Pink.new().foo() Lookup of the copy() method 15
  • 17. Lookup: Imports before Inheritance CollectionClassbox ImprovedClassbox PinkClassbox OrderedCollection OrderedCollection Pink do() do() foo() copy() 6 5 4 aSortedCollection.copy() SortedCollection SortedCollection SortedCollection 3 2 1 Pink.new().foo() Lookup of the copy() method 16
  • 18. Lookup: Imports before Inheritance The copy() method invokes do() one CollectionClassbox ImprovedClassbox PinkClassbox OrderedCollection OrderedCollection PinkClass do() do() foo() copy() 5 4 aSortedCollection.copy() SortedCollection SortedCollection SortedCollection 3 2 1 Without any drastic optimization, a system is 60% slower 17
  • 19. Conclusion • Definition of a module system for controlling class extensions: – Method addition and replacement are only visible in the module that defines them – Control the visibility – Support for unanticipated evolution • New method lookup – This has a price: slow performance with the current implementation 18
  • 20. Future Work • Allow aliasing, when importing • Refined visibility control (allowing an extension to be global: evolution of a classbox) • Add multiple Classbox interfaces (clients may see a classbox under different views) • Formalization to specify the flattening property 19
  • 21. Contact Information • Alexandre Bergel (bergel@iam.unibe.ch) • Website: – http://www.iam.unibe.ch/~scg/Research/Classboxes/index.html 20