SlideShare a Scribd company logo
1 of 21
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

What's hot

The Ring programming language version 1.4.1 book - Part 10 of 31
The Ring programming language version 1.4.1 book - Part 10 of 31The Ring programming language version 1.4.1 book - Part 10 of 31
The Ring programming language version 1.4.1 book - Part 10 of 31Mahmoud Samir Fayed
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBCJava OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBCOUM SAOKOSAL
 
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.4.1 book - Part 9 of 31The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.4.1 book - Part 9 of 31Mahmoud Samir Fayed
 
Collections Framework
Collections FrameworkCollections Framework
Collections FrameworkSunil OS
 
JDK1.7 features
JDK1.7 featuresJDK1.7 features
JDK1.7 featuresindia_mani
 
Java OOP Programming language (Part 4) - Collection
Java OOP Programming language (Part 4) - CollectionJava OOP Programming language (Part 4) - Collection
Java OOP Programming language (Part 4) - CollectionOUM SAOKOSAL
 
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.6 book - Part 36 of 189The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.6 book - Part 36 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202Mahmoud Samir Fayed
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
C h 04 oop_inheritance
C h 04 oop_inheritanceC h 04 oop_inheritance
C h 04 oop_inheritanceshatha00
 
The Ring programming language version 1.7 book - Part 29 of 196
The Ring programming language version 1.7 book - Part 29 of 196The Ring programming language version 1.7 book - Part 29 of 196
The Ring programming language version 1.7 book - Part 29 of 196Mahmoud Samir Fayed
 
From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019Leonardo Borges
 
XQuery Extensions
XQuery ExtensionsXQuery Extensions
XQuery ExtensionsAaron Buma
 
Javascript foundations: Classes and `this`
Javascript foundations: Classes and `this`Javascript foundations: Classes and `this`
Javascript foundations: Classes and `this`John Hunter
 

What's hot (20)

Chapter ii(oop)
Chapter ii(oop)Chapter ii(oop)
Chapter ii(oop)
 
The Ring programming language version 1.4.1 book - Part 10 of 31
The Ring programming language version 1.4.1 book - Part 10 of 31The Ring programming language version 1.4.1 book - Part 10 of 31
The Ring programming language version 1.4.1 book - Part 10 of 31
 
Java
JavaJava
Java
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBCJava OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBC
 
The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.4.1 book - Part 9 of 31The Ring programming language version 1.4.1 book - Part 9 of 31
The Ring programming language version 1.4.1 book - Part 9 of 31
 
4 gouping object
4 gouping object4 gouping object
4 gouping object
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
JDK1.7 features
JDK1.7 featuresJDK1.7 features
JDK1.7 features
 
Java OOP Programming language (Part 4) - Collection
Java OOP Programming language (Part 4) - CollectionJava OOP Programming language (Part 4) - Collection
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.6 book - Part 36 of 189The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.6 book - Part 36 of 189
 
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202
 
Python lec5
Python lec5Python lec5
Python lec5
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
C h 04 oop_inheritance
C h 04 oop_inheritanceC h 04 oop_inheritance
C h 04 oop_inheritance
 
Python lec4
Python lec4Python lec4
Python lec4
 
The Ring programming language version 1.7 book - Part 29 of 196
The Ring programming language version 1.7 book - Part 29 of 196The Ring programming language version 1.7 book - Part 29 of 196
The Ring programming language version 1.7 book - Part 29 of 196
 
Inheritance
InheritanceInheritance
Inheritance
 
From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019
 
XQuery Extensions
XQuery ExtensionsXQuery Extensions
XQuery Extensions
 
Javascript foundations: Classes and `this`
Javascript foundations: Classes and `this`Javascript foundations: Classes and `this`
Javascript foundations: Classes and `this`
 

Similar to Classboxes: A Minimal Module Model Supporting Local Class Extension

Feltman collections
Feltman collectionsFeltman collections
Feltman collectionsMike Feltman
 
Spock: Test Well and Prosper
Spock: Test Well and ProsperSpock: Test Well and Prosper
Spock: Test Well and ProsperKen Kousen
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84Mahmoud Samir Fayed
 
Collections in java
Collections in javaCollections in java
Collections in javakejpretkopet
 
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 
Python concurrency: libraries overview
Python concurrency: libraries overviewPython concurrency: libraries overview
Python concurrency: libraries overviewAndrii Mishkovskyi
 
More topics on Java
More topics on JavaMore topics on Java
More topics on JavaAhmed Misbah
 
A Scala tutorial
A Scala tutorialA Scala tutorial
A Scala tutorialDima Statz
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Ruslan Shevchenko
 
Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestHoward Lewis Ship
 
Object-Oriented Programming with C#
Object-Oriented Programming with C#Object-Oriented Programming with C#
Object-Oriented Programming with C#Svetlin Nakov
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88Mahmoud Samir Fayed
 

Similar to Classboxes: A Minimal Module Model Supporting Local Class Extension (20)

Feltman collections
Feltman collectionsFeltman collections
Feltman collections
 
Scala oo
Scala ooScala oo
Scala oo
 
Spock: Test Well and Prosper
Spock: Test Well and ProsperSpock: Test Well and Prosper
Spock: Test Well and Prosper
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
Inheritance
InheritanceInheritance
Inheritance
 
Collections
CollectionsCollections
Collections
 
Collections in java
Collections in javaCollections in java
Collections in java
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Python concurrency: libraries overview
Python concurrency: libraries overviewPython concurrency: libraries overview
Python concurrency: libraries overview
 
More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
A Scala tutorial
A Scala tutorialA Scala tutorial
A Scala tutorial
 
Java Reflection Concept and Working
Java Reflection Concept and WorkingJava Reflection Concept and Working
Java Reflection Concept and Working
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version]
 
Spock: A Highly Logical Way To Test
Spock: A Highly Logical Way To TestSpock: A Highly Logical Way To Test
Spock: A Highly Logical Way To Test
 
Design patterns(red)
Design patterns(red)Design patterns(red)
Design patterns(red)
 
Object-Oriented Programming with C#
Object-Oriented Programming with C#Object-Oriented Programming with C#
Object-Oriented Programming with C#
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
 
Design patterns
Design patternsDesign patterns
Design patterns
 
What's New In JDK 10
What's New In JDK 10What's New In JDK 10
What's New In JDK 10
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Recently uploaded (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Classboxes: A Minimal Module Model Supporting Local Class Extension

  • 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