16
Brief Introduction to Object-Oriented Frameworks Kurt Stirewalt

Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

Brief Introduction to Object-Oriented Frameworks

Kurt Stirewalt

Page 2: Brief Introduction to Object- Oriented 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

Page 3: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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).

Page 4: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

Brief example (and notation)

addActionListener(…)

Button ActionListener

actionPerformed(…)

MyApplicationClass

actionPerformed(…)

Page 5: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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.

Page 6: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

Example: Java AWT Framework

Page 7: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

Example instantiation: Online orders

Applet Button TextBox Panel …

OrderEntryApplet StoreFrontDisplay

Page 8: Brief Introduction to Object- Oriented 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

Page 9: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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

Page 10: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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

Page 11: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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

Page 12: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

Black-box evolution of AWT

• Observe: Can take a long time to migrate a white-box to a black-box framework

White-box Black-box

AWT v1.0 AWT v1.1 JFC/Swing

Page 13: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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

Page 14: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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

Page 15: Brief Introduction to Object- Oriented 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

Page 16: Brief Introduction to Object- Oriented Frameworks Kurt Stirewalt

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