Title: Classes and Connectors
1Classes and Connectors
- Dr. Uwe Aßmann
- Institut für Programmstrukturen
- Universität Karlsruhe
- Andreas Ludwig
- Rainer Neumann
2 Mass Produced SW Components
- Douglas McIlroy
- 1968
- NATO Science Conference Garmisch
- The inventor of pipes
3Overview
- Architecture and component systems
- Architecture with connectors as meta-programs
- Reengineering
- COMPOST, the COMPOsition sySTem
- Conclusions and Outlook
41) Motivation and Goal
- Communication code is weaved into systems
- Systems are not scalable
- De-weaving of communication code is hard
- Adaptation of legacy systems to new frameworks is
difficult - ?
- Segregate communication code into connectors
- Let connectors generate glue code between
components - De-weave automatically
- Adapt old systems automatically
5Architectural Systems
- Architectural systems propose separation of
architectural aspect by - decoupling architectural and application code.
Interface
Port
Component
Connector
Component
6Component Systems (CORBA, DCOM, ..)
- Component systems provide a
- communication infrastructure.
- Todays component systems...
- provide a monolithic infrastructure
- support many features at a high price
- provide one connector distr. communication
- Tomorrows component systems...
- should provide connector libraries
- adaptable and efficient
7Scenario for Standard OO
method-basedsingle-threadedlocal user client
ObserverSynchronizationCORBA
event-basedmulti-threadednetwork client
OO-Components of System A
OO-Components of System B
But how do I realize connectors in standard OO?
8The Idea Meta-Programming
MOP
OO-Components of System A
OO-Components of System B
COMPOST
ObservifierSynchronizerCORBAfier
9Issues...
- Connectors as Meta-Programs
- Example
- Reengineering Architecture
- Port Identification
- Source Code Hygiene
- Binary Components
- Integration into Process Management
- Version control
- System configuration
102) A Simple View on Connectors
- Connectors are...
- static meta-programs (program transformations),
introducing glue code in order to link ports,
working at compile time - components, containing communication code
- Ports are ...
- marked calls (naming scheme)
11Calling Connectors
.... Port port1, port2 Connector
connector connector.observify(Port1, Port2)
12Handling of Static Meta-Programs
- Interactive parameterization
- Guided by wizard in an IDE or CASE tool
- Source-based parameter specification
- Called by other transformations via library
interface - Separate composition procedures, filtered out by
compiler - Standalone composition meta-program
(architectural meta-program) - wrapped with driver, called in a shell
- Called automatically during translation
- Connectors weave communication code into
application code
13Static Code Compositionwith static
metaprogramming
Java plus extensions
Meta program
Java
COMPOST
OpenJava
MOP
Java compiler
MOP
Java
Java
Java compiler
Java compiler
Class file
Class file
14Example Observifier
- In 2 classes (subject, observer), list of ports
in subject to replace - Out 3 classes (subject, observer, event), where
- subject knows an observer
- ports are replaced by event notifications
- event class encapsulates the method parameters
- Typical engineering (weaving) problem
- How do we introduce the connector Observer into a
program? How do we generate glue code?
15Weaving Towers of Hanoi
Hanoi
compute
import java.io. public class Hanoi public
Hanoi() .. protected void compute( int n,
String s,
String t, String h ) if(n gt 1)
compute( n - 1, s, h, t ) move(s,t)
DISPLAY_PORT() if(n gt 1)
compute( n - 1, h, t, s )
Hanoi
PrintObserver
compute
display
event
16Observified Towers
import java.io. public class Hanoi extends
java.util.Observable implements
java.util.Observer public Hanoi()
addObserver( new PrintObserver() ) protected
void compute( int n, String s, String t, String h
) if(n gt 1) compute( n - 1, s, h, t
) move(s,t) setChanged()
notifyObservers( new displayPack( s, t ) )
if(n gt 1) compute( n - 1, h, t, s )
import java.io. public class Hanoi public
Hanoi() .. protected void compute( int n,
String s, String t, String h ) if(n gt 1)
compute( n - 1, s, h, t )
move(s,t) DISPLAYPORT() if(n gt 1)
compute( n - 1, h, t, s )
17(No Transcript)
18Phases Observifier Connector
- Initialization phase
- make classes accessible to COMPOST MOP, i.e. read
in classes - Identification phase
- identifiy port declarations
- pattern match places in code where to weave
- Transformation phase
- deweave remove weaved parts
- weave allocate gluecode for events, adapt
interfaces as Observable - Emitting phase
- Pretty print modified classes and glue code
19Phases Towers of Hanoi
ObservifierDriver.java
Glue code
Hanoi.java
COMPOST Observifier
Java
MOP
Observified code
Hanoi.java-1
Parameter packer
PrintObserver
Java compiler
20Invasive Composition
- ... transforms components
- during the embedding into a reuse context.
- Composers are program transformers.
21Composers Generalize Connectors
- Invasive composition
- components composers hooks
- components connectors ports
22Other Possible Invasive Connectors
- Pipe connectors
- streams cross ports (buffering, asynchronity)
- Connectors for standard component systems
- Beanifier
- Corbifier (IDL Generator)
- Control-flow connectors/coordinators
- data parallel
- make-connector controls jobs
23Other COMPOST Invasive Composers
- Multiple inheritance
- Mixin-based inheritance
- Generic type parameters
- Generic meta-objects
- Refactorings
- Portification and componentification of legacy
systems
24(No Transcript)
253) Reengineering
- Connector Meta-Programs Deweave
- match weaved code and replace it
- transform old code into new versions
- Identify and Introduce Ports
- match weaved code and replace it by ports
- General reengineering operations
- refactoring
26Port Identification
- All method calls can be reduced to ports
- pack all parameters into a convenience class
- Declared methods are provided ports
- Additional join points exist, such as
- method body entries and exits
- feature and parameter declaration lists
- relevant internal states
- Ports can be identified from other patterns
- Calls to Port classes
- Calls to special methods
- Access to shared data
27Port Identification
28De-/Weaving Process
Portified system modified communications
Final weaved system
29Observifier Deweaves Callsto Ports
Hanoi
Hanoi
Hanoi
compute
compute
compute
PrintObserver
event
display
event
event
call
display
display
display
Deweaving
Weaving
30Reengineering Portifier
- Initialization phase
- Identification phase
- deweaving select a call to be replaced by the
Observer pattern, i.e. the event-signalling code - Transformation phase
- deweave remove weaved parts, i.e. calls
- insert port
- (weave)
- Emitting phase
31Source Code Hygiene
- Important for incremental software development
with automated transformations - Obtained by a smart Pretty-Printer
- reformat only the new parts
- formatting style can be customized
32 Binary and Bytecode Components
- Can be wrapped
- but old code could still call new code
- not very efficient (black-box)
- wrapping creates object schizophrenia
- Can be transformed on machine language level via
binary meta-model - low-level model is more difficult to manipulate
- low-level model is restricted
334) Integration into Software Process Management
- Global configuration of architecture in
Composition Classes - standard version management
- standard software process tooling
- make as driver program
- configuration tools
- Local configuration of single connectors
- If-control structures configure (replace ifdefs)
34The Global Picture
Components
make
Makefile
Component Architecture
Composition programs
355) The COMPOsition SyTem
- COMPOST is the first system to support invasive
software composition - Library of meta-programs, also connectors
- Further meta-level information
- Names Types (for globally correct replacements)
- Box Components generalize components
- Hooks generalize ports
- Design Patterns
- Refactorings
- Contracts
- Inheritance operators
36The COMPOST Architecture
Wizards
AspectLanguages
Reengineering
Connectors
Language Add-Ons
Design Patterns
Inheritance
Refactorings
Boxes and Hooks
Prettyprinter
Type Information
Components
Database
Meta-Object Protocol (AST)
37Advantages
- Connectors are Programs
- Standard tooling available
- Standard software process management
- Open systems
- Scalable systems by simple configuration
- Connectors are components
- can be composed themselves
- uniformity
- connector reuse from libraries
- Better reuse!
38Relation to Other Works
- Connectors are higher-order functions, expanded
at compile time (functional programming) - Connectors are program transformers
- Connectors can be derived from design patterns
(software engineering)
39Visions
- Components are modules (classes) plus a notion of
composition interfaces that facilitate adaption
and composition. - Hooks generalize Ports for a uniform composition
mechanism - Composition libraries will become the foundation
of a new software industrial branch. - Meta-models replace languages?!
40COMPOST for Everybody
- First working release soon with
- parsers pretty printers, name analysis service
- transformations basic patterns, connectors,
inheritance - papers
- http//i44www.info.uni-karlsruhe.de/assmann/compo
st.html - What you can do
- write language adapters (C,..)
- extend COMPOST with new connectors and operators
- apply it to adapt your code!
41What is a Component?
- Module
- Parametrization Adaptation
- Extensibility Aspect separation
- Standards
42At the Transition to the COMPOSiTion Age
- XML will be the ASCII of the 21st century
- concrete syntax will vanish
- We need composition, not components
- Composition will substitute programming
- Invasive composition is required
- Forget about the language wars everything can be
composed which has abstract syntax - Become a developer of composition techniqes!
43(No Transcript)