Download OO frameworks

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Computational fluid dynamics wikipedia , lookup

Transcript
Brief Introduction to ObjectOriented Frameworks
Kurt Stirewalt
Overview of talk
• OO Frameworks:
– Definitions and characteristics
– Example: Java AWT
• Issues in framework design:
– Usability
– Extensibility, efficiency, and maintenance
• Frameworks and code generation
Object-Oriented Frameworks
• A.k.a: Object-oriented abstract design:
• Salient features:
– Corpus of (partially implemented) classes
– Framework classes expect to collaborate with others
– Instantiated by subclassing framework classes and
providing or over-riding polymorphic operations
• Many well-known examples:
o Modern UI toolkits (e.g., Java AWT, subArctic, MFC).
o Distributed computing toolkits (e.g., ACE).
Brief example (and notation)
Button
ActionListener
addActionListener(…)
actionPerformed(…)
MyApplicationClass
actionPerformed(…)
Frameworks programming model
• Often:
o User-defined methods invoked by framework code.
o Framework plays the role of ``main program''.
• This inversion of control allows frameworks to
serve as extensible code skeletons.
• User-supplied methods tailor generic framework
algorithms for a specific application.
Example: Java AWT Framework
Example instantiation: Online orders
Applet
Button
OrderEntryApplet
TextBox
Panel
…
StoreFrontDisplay
Overview of talk
• OO Frameworks:
– Definitions and characteristics
– Example: Java AWT
• Issues in framework design:
– Usability
– Extensibility, efficiency, and maintenance
• Frameworks and code generation
Issues in framework design
• Usability:
– Some frameworks require more implementation
knowledge to use than others
– White- vs. black-box distinction
• Extensibility/maintenance:
– Successful frameworks get large and bulky
– Monolithic vs. collaboration-stratified
frameworks
Framework usability
“The AWT[1.0] event model is the son of Satan!”
-- Ian Smith, subArctic developer
• White-box:
– Override to customize
– Internal structure of classes exposed
• Black-box:
– Configure to customize
– Only interfaces exposed
Example: AWT event handling
• White box (version 1.02)
– Every UI component had handleEvent method
– To catch events, define subclass and override method
• Black box (version 1.1)
– UI components “fire” events to interested listeners
– Objects that implement a listener interface can register
for event notification from a UI component
• Instantiation in 1.1 uses knowledge of an abstract
protocol, not UI-component implementation
Black-box evolution of AWT
AWT v1.0
White-box
AWT v1.1
JFC/Swing
Black-box
• Observe: Can take a long time to migrate a
white-box to a black-box framework
Why is black-box better?
• Possible answers:
–
–
–
–
Maturity of product
Separation of concerns
Better conceptual abstractions
Better understanding of key collaborations
• Observe: All of these features are important
for code generation
Maintenance & Evolution
• Problem: Framework classes can get bulky
– Function of dependencies among the classes
– Also backward compatibilty in presence of new
features.
– But, not all classes communicate with all others!
• Rather, classes involved in smaller collaborations.
– Classes play roles in a collaboration
– Role often involves only subset of class’ operations
• Solution: GenVoca style layering/composition
useful for organizing frameworks
Overview of talk
• OO Frameworks:
– Definitions and characteristics
– Example: Java AWT
• Issues in framework design:
– Usability
– Extensibility, efficiency, and maintenance
• Frameworks and code generation
Frameworks and code generation
Easier to build tool to specialize well-defined classes than to
build a general-purpose code generator
– [Johnson & Foote’88].
• Frameworks provide:
– (partial) specification for new components and
– template for implementing them
• UML class/state diagrams good at representing framework
classes and behaviors
• Meridian: Can we automatically instantiate framework
classes from UML-model specifications