SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Enabling White-Box Reuse in a
 Pure Composition Language

       Andreas Schlapbach
      schlpbch@iam.unibe.ch

         January, 2003.
Overview

 • Introduction

    – Component-based software development.
    – Roles of inheritance.
    – Subclassing as a form of white-box reuse.
    – Subclassing considered harmful.

 • Goal

    – To combine the power of inheritance with the
      ease of scripting.

 • Solution

    – Piccola, our composition language.
    – Introduce a language extension to JPiccola that
      enables inheritance.
    – Implementation and examples.
    – Applications.

 • Lessons Learned

 • Questions & Comments

                                              2
Component-based Software Development




 • Modern applications must be flexible and
   extendible to adapt to changing require-
   ments.


 • These requirements can be addressed best
   by a component-oriented software devel-
   opment approach.


 • Component-oriented software development
   shifts away from programming towards soft-
   ware composition.




                                       3
Scripting Real-World Components


 • Applications = Components + Script
                  + a Drop of Glue.




 • We build applications by scripting compo-
   nents.


 • These components must adhere to a com-
   positional style.


 • In reality, such components often do not
   exist.


£ We have to adapt existing components, us-
ing a drop of glue.

                                       4
Adaptation: Black-box versus White-box


White-box Reuse. Adapts a mismatched com-
  ponent by either changing or overriding its
  internal specification.

   E.g.: Copy & Paste, Inheritance


Black-box Reuse. Adapts the interface of a
   component only.

   E.g.: Wrapping techniques, Reflective ap-
   proach, Standardization




                                       5
Roles of Inheritance

Inheritance is a key concept of object-oriented
languages and plays different roles:


Subclassing. At the implementation level, it
   is a means for code reuse.


Subtyping. At the design level, it defines a
   substitutability relationship.


Is-a Relationship. At the conceptual level, it
    represents a conceptual specialization rela-
    tionship.


These roles of inheritance can conflict.


                                          6
Subclassing Considered Harmful


 • Subclassing can break encapsulation by ac-
   cessing internal implementation details of
   an object.


 • Subclassing introduces subtle dependencies
   between base and extending classes.


 • Subclassing is a white-box form of reuse.


£ Let’s minimize the use of inheritance.




                                           7
Goal: Migrate from Class Inheritance to
Object Composition


 • There are many powerful object-oriented
   frameworks we would like to reuse as black-
   box components.


 • We need inheritance to access their func-
   tionality.


 • Our approach is to gain access to the com-
   ponents of a framework using inheritance,
   wrap them and script those wrapped com-
   ponents.


£ We would like to have the power of inheri-
tance combined with the ease of scripting.

                                        8
Piccola


 • Piccola is a small, pure and general pur-
   pose scripting language.


 • Piccola is based on forms, agents and chan-
   nels: Agents communicate by sending forms
   along channels.


 • Forms are extensible records unified with
   services. Everything is a form.


 • JPiccola is the Java-based implementation
   of Piccola.



                                        9
A Language Extension for JPiccola

We want to use Java frameworks in Piccola
using inheritance.

Key idea: Create Java objects implementing
a given type that delegate all calls to its meth-
ods to Piccola services.

                           func(args):
                                ...
Java
                                result
          up(args)                       down(result)



Piccola   func(arg1, arg2,...,argn)




£ We have to generate classes of a given type
at runtime.

                                               10
Implementation I

The class generation process consists of three
steps:


1. Gather information on the structure of the
   class.


2. Generate the class, using the BCEL byte
   code engineering library.


3. Load the class into the Java Virtual Ma-
   chine, using a custom class loader.




                                        11
Structure of a Generated Class I

Let’s suppose we have class A with a method
plus(int i, int j). We define a service plus
in Piccola to handle calls to this method.

plus(args):
  ’i = args.at(1)
  ’j = args.at(2)
  i + j

We generate a subclass of A and redirect the
Java call to a Piccola service:

public int plus(int j, int j) {
  Arguments args = new Arguments();
  args.add(this);
  args.add(new Integer(i));
  args.add(new Integer(j));
  return ((Integer) getService(quot;plusquot;)
          .callback(args)).intValue();
}
                                       12
Structure of a Generated Class II
Actually, we generate byte code.
Method int plus(int, int)
  0 new #22 <Class ch.unibe.piccola.bridge.Arguments>
  3 dup
  4 invokespecial #23
      <Method ch.unibe.piccola.bridge.Arguments()>
  7 astore 4
  9 aload 4
 11 aload_0
 12 invokevirtual #27 <Method void add(java.lang.Object)>
 15 aload 4
 17 new #56 <Class java.lang.Integer>
 20 dup
 21 iload_1
 22 invokespecial #65 <Method java.lang.Integer(int)>
 25 invokevirtual #27 <Method void add(java.lang.Object)>
 28 aload 4
 30 new #56 <Class java.lang.Integer>
 33 dup
 34 iload_2
 35 invokespecial #65 <Method java.lang.Integer(int)>
 38 invokevirtual #27 <Method void add(java.lang.Object)>
 41 aload_0
 42 ldc #75 <String quot;plusquot;>
 44 invokevirtual #33
      <Method ch.unibe.piccola.IForm
        getService(java.lang.String)>
 47 aload 4
 49 invokeinterface (args 2) #39
      <InterfaceMethod java.lang.Object
        callback(ch.unibe.piccola.bridge.Arguments)>
 54 checkcast #56 <Class java.lang.Integer>
 57 invokevirtual #60 <Method int intValue()>
 60 ireturn
                                                  13
Example I



generateSubclassOfA():

  newClass

      name = quot;Bquot;

      superClassName = quot;Aquot;

      interfaceNames = [ ]

      methods =

        plus =

             argumentTypeList =

                 [ Type.int, Type.int ]

             returnType = Type.int

             body(args): args.at(1) + args.at(2)




                                          14
Implementation II

Often, we do not need to generate an arbitrary
class but implement an interface or generate a
direct subclass of an abstract class.

£ We can use reflection to gather the infor-
mation needed to generate a class.




                                        15
Example II



generateKeyListener():

  newInterface

      className = quot;java.awt.event.KeyListenerquot;

      methods =

        keyPressed(args):   println quot;Key Pressedquot;

        keyReleased(args): println quot;Key Releasedquot;

        keyTyped(args):     println quot;Key Typedquot;




                                         16
Applications


 • Print Service


 • Scripting an Event Based Parser


 • Scripting Web Browser Frameworks


 • GUI Event Composition Style


 • ...


£ We use the language extension whenever we
need inheritance.


                                      17
Role of Java Interfaces in Frameworks


 • We seldom generate arbitrary classes, most
   often we just implement Java interfaces.
   Why is this?


 • A framework consists of ready-to-use and
   half finished building blocks.


 • While most parts are stable, it permits its
   user to adapt parts of it according to their
   needs. These are the hot spots of a frame-
   work.


 • Superior to (abstract) classes, interfaces
   do not impose a specific inheritance hier-
   archy.


£ Java interfaces provide a good way to con-
trol the type of adaptations compatible with a
framework.
                                         18
Closing Remarks


 • The language extension integrates nicely
   into JPiccola.


 • Good components are hard to find.


 • A framework is more than a bundle of classes.




                                        19
Questions & Comments




                       20
ClassFile
ClassFile {
  u4 magic;
  u2 minor_version;
  u2 major_version;
  u2 constant_pool_count;
  cp_info constant_pool[constant_pool_count-1];
  u2 access_flags;
  u2 this_class;
  u2 super_class;
  u2 interfaces_count;
  u2 interfaces[interfaces_count];
  u2 fields_count;
  field_info fields[fields_count];
  u2 methods_count;
  method_info methods[methods_count];
  u2 attributes_count;
  attribute_info attributes[attributes_count];
}




                                         21

Mais conteúdo relacionado

Mais procurados

50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutesArun Gupta
 
GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionStephen Colebourne
 
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Baruch Sadogursky
 
Getting Started with Java EE 7
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7Arun Gupta
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Julian Robichaux
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Ryan Cuprak
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsShekhar Gulati
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Ryan Cuprak
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Saeed Zarinfam
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppEdureka!
 

Mais procurados (20)

Hibernate
HibernateHibernate
Hibernate
 
50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
 
Java presentation
Java presentationJava presentation
Java presentation
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
 
Reactjs
ReactjsReactjs
Reactjs
 
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
 
Maven
MavenMaven
Maven
 
Core java
Core javaCore java
Core java
 
Getting Started with Java EE 7
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
 
Maven
MavenMaven
Maven
 
From JavaEE to AngularJS
From JavaEE to AngularJSFrom JavaEE to AngularJS
From JavaEE to AngularJS
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 

Destaque

Why should we use an INTERFACE even when we only have one concrete class?
Why should we use an INTERFACE even when we only have one concrete class?Why should we use an INTERFACE even when we only have one concrete class?
Why should we use an INTERFACE even when we only have one concrete class?Rafal Ksiazek
 
Scaling Rails with memcached
Scaling Rails with memcachedScaling Rails with memcached
Scaling Rails with memcachedelliando dias
 
Scrum in five minutes
Scrum in five minutesScrum in five minutes
Scrum in five minuteselliando dias
 
Programmable Matter with Modular Robots
Programmable Matter with Modular RobotsProgrammable Matter with Modular Robots
Programmable Matter with Modular Robotselliando dias
 
A Brief Tour of Responsability Driven Design
A Brief Tour of Responsability Driven DesignA Brief Tour of Responsability Driven Design
A Brief Tour of Responsability Driven Designelliando dias
 
HTML5: The New html for the web
HTML5: The New html for the webHTML5: The New html for the web
HTML5: The New html for the webelliando dias
 
Assembling wall panels with robotic technologies
Assembling wall panels with robotic technologiesAssembling wall panels with robotic technologies
Assembling wall panels with robotic technologieselliando dias
 
Gerenciamento de Projetos OO
Gerenciamento de Projetos OOGerenciamento de Projetos OO
Gerenciamento de Projetos OOelliando dias
 
Model-Driven Software Development
Model-Driven Software DevelopmentModel-Driven Software Development
Model-Driven Software Developmentelliando dias
 
How to Design Frameworks
How to Design FrameworksHow to Design Frameworks
How to Design Frameworkselliando dias
 
How To Build A Better Arduino
How To Build A Better ArduinoHow To Build A Better Arduino
How To Build A Better ArduinoAlastairDSilva
 
Interfaces de Usuário Ubíquas - UUI
Interfaces de Usuário Ubíquas - UUIInterfaces de Usuário Ubíquas - UUI
Interfaces de Usuário Ubíquas - UUIelliando dias
 
hardware de um sistema de computação
hardware de um sistema de computaçãohardware de um sistema de computação
hardware de um sistema de computaçãoelliando dias
 
Representação de Números
Representação de NúmerosRepresentação de Números
Representação de Númeroselliando dias
 
Linguagens de Transformação de Modelos
Linguagens de Transformação de ModelosLinguagens de Transformação de Modelos
Linguagens de Transformação de Modeloselliando dias
 
UML-Based Web Engineering
UML-Based Web EngineeringUML-Based Web Engineering
UML-Based Web Engineeringelliando dias
 
Gerenciamento de Projeto para Desenvolvimento de Sistema
Gerenciamento de Projeto para Desenvolvimento de SistemaGerenciamento de Projeto para Desenvolvimento de Sistema
Gerenciamento de Projeto para Desenvolvimento de Sistemaelliando dias
 

Destaque (20)

Why should we use an INTERFACE even when we only have one concrete class?
Why should we use an INTERFACE even when we only have one concrete class?Why should we use an INTERFACE even when we only have one concrete class?
Why should we use an INTERFACE even when we only have one concrete class?
 
Scaling Rails with memcached
Scaling Rails with memcachedScaling Rails with memcached
Scaling Rails with memcached
 
Scrum in five minutes
Scrum in five minutesScrum in five minutes
Scrum in five minutes
 
Programmable Matter with Modular Robots
Programmable Matter with Modular RobotsProgrammable Matter with Modular Robots
Programmable Matter with Modular Robots
 
A Brief Tour of Responsability Driven Design
A Brief Tour of Responsability Driven DesignA Brief Tour of Responsability Driven Design
A Brief Tour of Responsability Driven Design
 
HTML5: The New html for the web
HTML5: The New html for the webHTML5: The New html for the web
HTML5: The New html for the web
 
Assembling wall panels with robotic technologies
Assembling wall panels with robotic technologiesAssembling wall panels with robotic technologies
Assembling wall panels with robotic technologies
 
Gerenciamento de Projetos OO
Gerenciamento de Projetos OOGerenciamento de Projetos OO
Gerenciamento de Projetos OO
 
Model-Driven Software Development
Model-Driven Software DevelopmentModel-Driven Software Development
Model-Driven Software Development
 
How to Design Frameworks
How to Design FrameworksHow to Design Frameworks
How to Design Frameworks
 
Acme Total
Acme TotalAcme Total
Acme Total
 
How To Build A Better Arduino
How To Build A Better ArduinoHow To Build A Better Arduino
How To Build A Better Arduino
 
Algoritmo Genetico
Algoritmo GeneticoAlgoritmo Genetico
Algoritmo Genetico
 
Interfaces de Usuário Ubíquas - UUI
Interfaces de Usuário Ubíquas - UUIInterfaces de Usuário Ubíquas - UUI
Interfaces de Usuário Ubíquas - UUI
 
hardware de um sistema de computação
hardware de um sistema de computaçãohardware de um sistema de computação
hardware de um sistema de computação
 
Representação de Números
Representação de NúmerosRepresentação de Números
Representação de Números
 
Linguagens de Transformação de Modelos
Linguagens de Transformação de ModelosLinguagens de Transformação de Modelos
Linguagens de Transformação de Modelos
 
Robótica Móvel
Robótica MóvelRobótica Móvel
Robótica Móvel
 
UML-Based Web Engineering
UML-Based Web EngineeringUML-Based Web Engineering
UML-Based Web Engineering
 
Gerenciamento de Projeto para Desenvolvimento de Sistema
Gerenciamento de Projeto para Desenvolvimento de SistemaGerenciamento de Projeto para Desenvolvimento de Sistema
Gerenciamento de Projeto para Desenvolvimento de Sistema
 

Semelhante a Enabling White-Box Reuse in a Pure Composition Language

Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)smumbahelp
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011YoungSu Son
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019Paulo Clavijo
 
Java Standard edition(Java ) programming Basics for beginner's
Java Standard edition(Java ) programming Basics  for beginner'sJava Standard edition(Java ) programming Basics  for beginner's
Java Standard edition(Java ) programming Basics for beginner'smomin6
 
50 common web developer interview questions [2020 updated] [www.full stack....
50 common web developer interview questions [2020 updated]   [www.full stack....50 common web developer interview questions [2020 updated]   [www.full stack....
50 common web developer interview questions [2020 updated] [www.full stack....Alex Ershov
 
Angular Intermediate
Angular IntermediateAngular Intermediate
Angular IntermediateLinkMe Srl
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)smumbahelp
 

Semelhante a Enabling White-Box Reuse in a Pure Composition Language (20)

Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Java notes
Java notesJava notes
Java notes
 
C# Unit 2 notes
C# Unit 2 notesC# Unit 2 notes
C# Unit 2 notes
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
 
All experiment of java
All experiment of javaAll experiment of java
All experiment of java
 
JAVA Collection and generics
JAVA Collection and genericsJAVA Collection and generics
JAVA Collection and generics
 
Java Standard edition(Java ) programming Basics for beginner's
Java Standard edition(Java ) programming Basics  for beginner'sJava Standard edition(Java ) programming Basics  for beginner's
Java Standard edition(Java ) programming Basics for beginner's
 
50 common web developer interview questions [2020 updated] [www.full stack....
50 common web developer interview questions [2020 updated]   [www.full stack....50 common web developer interview questions [2020 updated]   [www.full stack....
50 common web developer interview questions [2020 updated] [www.full stack....
 
Angular Intermediate
Angular IntermediateAngular Intermediate
Angular Intermediate
 
Complete Java Course
Complete Java CourseComplete Java Course
Complete Java Course
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 

Mais de elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

Mais de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Enabling White-Box Reuse in a Pure Composition Language

  • 1. Enabling White-Box Reuse in a Pure Composition Language Andreas Schlapbach schlpbch@iam.unibe.ch January, 2003.
  • 2. Overview • Introduction – Component-based software development. – Roles of inheritance. – Subclassing as a form of white-box reuse. – Subclassing considered harmful. • Goal – To combine the power of inheritance with the ease of scripting. • Solution – Piccola, our composition language. – Introduce a language extension to JPiccola that enables inheritance. – Implementation and examples. – Applications. • Lessons Learned • Questions & Comments 2
  • 3. Component-based Software Development • Modern applications must be flexible and extendible to adapt to changing require- ments. • These requirements can be addressed best by a component-oriented software devel- opment approach. • Component-oriented software development shifts away from programming towards soft- ware composition. 3
  • 4. Scripting Real-World Components • Applications = Components + Script + a Drop of Glue. • We build applications by scripting compo- nents. • These components must adhere to a com- positional style. • In reality, such components often do not exist. £ We have to adapt existing components, us- ing a drop of glue. 4
  • 5. Adaptation: Black-box versus White-box White-box Reuse. Adapts a mismatched com- ponent by either changing or overriding its internal specification. E.g.: Copy & Paste, Inheritance Black-box Reuse. Adapts the interface of a component only. E.g.: Wrapping techniques, Reflective ap- proach, Standardization 5
  • 6. Roles of Inheritance Inheritance is a key concept of object-oriented languages and plays different roles: Subclassing. At the implementation level, it is a means for code reuse. Subtyping. At the design level, it defines a substitutability relationship. Is-a Relationship. At the conceptual level, it represents a conceptual specialization rela- tionship. These roles of inheritance can conflict. 6
  • 7. Subclassing Considered Harmful • Subclassing can break encapsulation by ac- cessing internal implementation details of an object. • Subclassing introduces subtle dependencies between base and extending classes. • Subclassing is a white-box form of reuse. £ Let’s minimize the use of inheritance. 7
  • 8. Goal: Migrate from Class Inheritance to Object Composition • There are many powerful object-oriented frameworks we would like to reuse as black- box components. • We need inheritance to access their func- tionality. • Our approach is to gain access to the com- ponents of a framework using inheritance, wrap them and script those wrapped com- ponents. £ We would like to have the power of inheri- tance combined with the ease of scripting. 8
  • 9. Piccola • Piccola is a small, pure and general pur- pose scripting language. • Piccola is based on forms, agents and chan- nels: Agents communicate by sending forms along channels. • Forms are extensible records unified with services. Everything is a form. • JPiccola is the Java-based implementation of Piccola. 9
  • 10. A Language Extension for JPiccola We want to use Java frameworks in Piccola using inheritance. Key idea: Create Java objects implementing a given type that delegate all calls to its meth- ods to Piccola services. func(args): ... Java result up(args) down(result) Piccola func(arg1, arg2,...,argn) £ We have to generate classes of a given type at runtime. 10
  • 11. Implementation I The class generation process consists of three steps: 1. Gather information on the structure of the class. 2. Generate the class, using the BCEL byte code engineering library. 3. Load the class into the Java Virtual Ma- chine, using a custom class loader. 11
  • 12. Structure of a Generated Class I Let’s suppose we have class A with a method plus(int i, int j). We define a service plus in Piccola to handle calls to this method. plus(args): ’i = args.at(1) ’j = args.at(2) i + j We generate a subclass of A and redirect the Java call to a Piccola service: public int plus(int j, int j) { Arguments args = new Arguments(); args.add(this); args.add(new Integer(i)); args.add(new Integer(j)); return ((Integer) getService(quot;plusquot;) .callback(args)).intValue(); } 12
  • 13. Structure of a Generated Class II Actually, we generate byte code. Method int plus(int, int) 0 new #22 <Class ch.unibe.piccola.bridge.Arguments> 3 dup 4 invokespecial #23 <Method ch.unibe.piccola.bridge.Arguments()> 7 astore 4 9 aload 4 11 aload_0 12 invokevirtual #27 <Method void add(java.lang.Object)> 15 aload 4 17 new #56 <Class java.lang.Integer> 20 dup 21 iload_1 22 invokespecial #65 <Method java.lang.Integer(int)> 25 invokevirtual #27 <Method void add(java.lang.Object)> 28 aload 4 30 new #56 <Class java.lang.Integer> 33 dup 34 iload_2 35 invokespecial #65 <Method java.lang.Integer(int)> 38 invokevirtual #27 <Method void add(java.lang.Object)> 41 aload_0 42 ldc #75 <String quot;plusquot;> 44 invokevirtual #33 <Method ch.unibe.piccola.IForm getService(java.lang.String)> 47 aload 4 49 invokeinterface (args 2) #39 <InterfaceMethod java.lang.Object callback(ch.unibe.piccola.bridge.Arguments)> 54 checkcast #56 <Class java.lang.Integer> 57 invokevirtual #60 <Method int intValue()> 60 ireturn 13
  • 14. Example I generateSubclassOfA(): newClass name = quot;Bquot; superClassName = quot;Aquot; interfaceNames = [ ] methods = plus = argumentTypeList = [ Type.int, Type.int ] returnType = Type.int body(args): args.at(1) + args.at(2) 14
  • 15. Implementation II Often, we do not need to generate an arbitrary class but implement an interface or generate a direct subclass of an abstract class. £ We can use reflection to gather the infor- mation needed to generate a class. 15
  • 16. Example II generateKeyListener(): newInterface className = quot;java.awt.event.KeyListenerquot; methods = keyPressed(args): println quot;Key Pressedquot; keyReleased(args): println quot;Key Releasedquot; keyTyped(args): println quot;Key Typedquot; 16
  • 17. Applications • Print Service • Scripting an Event Based Parser • Scripting Web Browser Frameworks • GUI Event Composition Style • ... £ We use the language extension whenever we need inheritance. 17
  • 18. Role of Java Interfaces in Frameworks • We seldom generate arbitrary classes, most often we just implement Java interfaces. Why is this? • A framework consists of ready-to-use and half finished building blocks. • While most parts are stable, it permits its user to adapt parts of it according to their needs. These are the hot spots of a frame- work. • Superior to (abstract) classes, interfaces do not impose a specific inheritance hier- archy. £ Java interfaces provide a good way to con- trol the type of adaptations compatible with a framework. 18
  • 19. Closing Remarks • The language extension integrates nicely into JPiccola. • Good components are hard to find. • A framework is more than a bundle of classes. 19
  • 21. ClassFile ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } 21