13 DPF Framework Extensibility
13 DPF Framework Extensibility
2
► E. Gamma. The Extension Objects Pattern. Conf. On Pattern Languages of
Programming (PLOP) 97, ACM. http://portal.acm.org/citation.cfm?id=273448.273455
► Y. Smaragdakis and D. Batory. Mixin layers: an object-oriented implementation
technique for refinements and collaboration-based designs. ACM Transactions
on Software Engineering and Methodology, 11(2):215–255, 2002.
http://dl.acm.org/citation.cfm?id=505148
Prof. Uwe Aßmann, Design Patterns and Frameworks
3
► D. Bäumer. Softwarearchitekturen für die rahmenwerkbasierte Konstruktion grosser
Anwendungssysteme. PhD thesis, 1997, Universität Hamburg.
► JWAM sites
– http://www.c1-wps.de/forschung-und-lehre/fachpublikationen/
– www.jwam.de
– http://sourceforge.net/projects/jwamtoolconstr/
Prof. Uwe Aßmann, Design Patterns and Frameworks
–
● Role Object and
● Genvoca
► Understand these patterns as extension points of frameworks,
i.e., framework hook patterns
Frameworks Must Be Extensible
– Layered frameworks
● Riehle/Züllighoven's RoleObject pattern (ROP)
● Batory's mixin layer pattern (GenVoca pattern)
13.1 The ExtensionObjects
Pattern (EOP)
6
7
► Whenever a complex object has non-mandatory parts that can be added, if necessary
► Extension is the base class of all extensions
► AbstractExtension defines an interface for a concrete hierarchy of extension objects
► Extensions can be added, retrieved, and removed by clients
Client
Prof. Uwe Aßmann, Design Patterns and Frameworks
Subject
getExtension(name) owner
Extension
addExtension(name, Extension)
removeExtension(name)
ConcreteSubject 1 or n
<<template>>
Document
owner <<hook>>
getExtension(name)
Extension
addExtension(name, Extension)
Prof. Uwe Aßmann, Design Patterns and Frameworks
removeExtension(name)
ConcreteDocument 1 or n
Spellchecker WordCounter
getExtension(name) extension
addExtension(name, Extension)
removeExtension(name)
<<template>>
Subject
Prof. Uwe Aßmann, Design Patterns and Frameworks
owner <<hook>>
getExtension(name)
Extension
addExtension(name, Extension)
removeExtension(name)
ConcreteSubject 1 or n
AbstractExtension1 AbstractExtension2
getExtension(name) extension
addExtension(name, Extension)
removeExtension(name)
1-H=T n-H=T
T has 1 H part T has n H parts
T owns H T owns H parts
Prof. Uwe Aßmann, Design Patterns and Frameworks
T 1 H T n H
T= H T = *H
Optional Tools for Documents in an Office
Framework
12
Office Framework
Prof. Uwe Aßmann, Design Patterns and Frameworks
Document
=
* SpellChecker
WordCount
a.s.o
13.2 Extensibility of Frameworks
with Layers
13
– Is a blackbox framework
► Desktop Layer
– Support for interactive workplaces
– Contains a tool construction framework (for the Tools&Materials
approach)
– MVC framework, Folder framework, Value framework for business and
domain values
● AccountNumber, ClientNumber, Money etc
– Look and feel, reusable for office domains with GUI applications
Layers
19
potential run-time
Business Section Layers access
Prof. Uwe Aßmann, Design Patterns and Frameworks
Customer
CustomerCore * CustomerRole
Role Object Pattern with Inheritance Drawn
Upwards
22 Business Domain Layer <<interfaces>>
<<template classes>>
Customer
CustomerCore * CustomerRole
Prof. Uwe Aßmann, Design Patterns and Frameworks
<<static>>
Client
Riehle/Züllighovens Role Object Pattern
Abstracted (“Deep Roles”)
23 Core Layer 1
Application <<interfaces>>
Conceptual
Client
Core * Role
Prof. Uwe Aßmann, Design Patterns and Frameworks
Layer 2
Layer 3
Core Role
*
Layer 2
Layer 3
25 ► Change of role:
– Different Role Objects may belong to the same role type (e.g.,
working for multiple companies)
– Over time, the role object for a player may change
– This expresses states of the player in the application
Prof. Uwe Aßmann, Design Patterns and Frameworks
addRole(ServiceDescription)
Interpret serviceDescription; removeRole()
add concrete role and service hasRole()
under service description giveRole()
in role map;
accept(ServiceDescription)
service1()
addRole() addRole()
removeRole() removeRole()
// Traded call // hasRole() hasRole()
Interpret serviceDescription; giveRole() giveRole()
Lookup concrete service
in role map; accept(ServiceDescription) accept(S.D.)
Call; service1() service1()
RoleObjectPattern and Other Patterns
Investor Savings
Account
Borrower Loan
Account
Role Object Pattern and Role Models on
Role Layers
30 ► Usually, roles of one subject talk to other roles of another subject on the
same layer (within a role model)
► Cores never talk to each other directly
Business Domain Layer
Customer Account
Prof. Uwe Aßmann, Design Patterns and Frameworks
Savings
Investor
Account
Borrower Loan
Account
Switching Variable Role Layers
Customer Account
Prof. Uwe Aßmann, Design Patterns and Frameworks
Garantee
Garantor
Contract
Borrower Loan
Account
Riehle/Züllighovens Layer Pattern As
Framework Hook Pattern
32
Role n-TrH H
T2 has H parts
n n
Conceptual T1
H and T2 inherit
from T1
Core T2
Prof. Uwe Aßmann, Design Patterns and Frameworks
H knows T1
Core-Role-Pattern
n-TrH mini-connector
Con R
C R C n R
R
ROP Ensures Extensibility
33 ► The ROP lends itself not only to variability, but also to dynamic
extensibility
– If a framework hook is a role object pattern, the hook can be
extended in unforeseen ways without changing the framework!
– New layers of the application or the framework can be added at
design time or runtime
Prof. Uwe Aßmann, Design Patterns and Frameworks
Core Layer R
Prof. Uwe Aßmann, Design Patterns and Frameworks
C R
R
13.4 The GenVoca Pattern, Mixin
Layers, and Layered Mixin
Frameworks
35
36
► A mixin is a partial class, for an extension of another class
► A mixin-base is a class with a generic super class, a mixin parameterizes this
► Some languages have mixins (Scala, C#, Eiffel); otherwise, mixins can be expressed as class
fragments that can be parameterized with a superclass (C++)
► Mixins can implement (static) roles and facets
Person
Prof. Uwe Aßmann, Design Patterns and Frameworks
template
template <class
<class S>
S>
class
class EmployeeMixin extends
EmployeeMixin extends SS {{ <<parameterize>>
//
// class
class extension..
extension..
Salary salary;
Salary salary;
Employer
Employer emp;
emp; EmployeeMixin
}}
EmployeeMixin<Person>
EmployeeMixin<Person> employeeOfPerson;
employeeOfPerson;
EmployeeMixin<German> employeeOfGerman;
EmployeeMixin<German> employeeOfGerman; EmployedPerson
EmployeeMixin<Club>
EmployeeMixin<Club> employeeOfClub;
employeeOfClub;
The GenVoca Pattern
// Compositions
// Compositions
GolfPlayer<PermanentEmployee<Father<Man>>>> assmann;
GolfPlayer<PermanentEmployee<Father<Man>>>> assmann;
Gamer<TimedEmployee<Father<Man>>>> miller;
Gamer<TimedEmployee<Father<Man>>>> miller;
GolfPlayer<PermanentEmployee<Mother<Woman>>>> brown;
GolfPlayer<PermanentEmployee<Mother<Woman>>>> brown;
Variations on Different Abstraction Layers
form Product Variants
39 ► Variants can be formed on every layer
<<parameterize>>
Prof. Uwe Aßmann, Design Patterns and Frameworks
<<parameterize>>
Permanent
EmployeeMixin TimedEmployee
Employee
<<parameterize>>
<<parameterize>>
Prof. Uwe Aßmann, Design Patterns and Frameworks
<<parameterize>>
Permanent
EmployeeMixin TimedEmployee
Employee
<<parameterize>>
42
► While the GenVoca pattern deals with single stacking of parameterizations, the MixinLayer
pattern groups all roles of an abstraction layer together and composes entire layers
► MixinLayer treats all logical objects of an application
<<parameterize>>
<<parameterize>>
<<parameterize>>
FullTimeLayer
FullTimePerson FullTimeWork FullTimeLocation
PartTimeLayer PartTimePerson PartTimeWork PartTimeLocation
Prof. Uwe Aßmann, Design Patterns and Frameworks
<<parameterize>>
FatherLayer
Father ChangingDiapers Toilet
MotherLayer Mother BreastFeeding ChildrensRoom
<<parameterize>>
Deliberate NoContract Deliberate Home
<<parameterize>>
WorkAsHobby ChildrenAsHobby
WorkNotAs ChildrenNotAs
Hobby Hobby
Composition of Mixin Layers
class
class Layer
Layer <class
<class Super,
Super, class
class RoleSuper
RoleSuper1,1, ..,
.., class
class RoleSuper
RoleSupern>n>
extends
extends Super
Super {{
class
class Role
Role1 1 extends
extends RoleSuper
RoleSuper1 1 {{ ..
.. }}
..
..
class
class Role
Rolen extends
extends RoleSuper
RoleSupern {{ .. .. }}
n n
..
.. additional
additional classes..
classes..
}}
Implementation of Mixin Layers with
Designated Inner Classes
46 ► If the target language permits to have inner classes that can be
designated by an expression, mixin layers can be inherited as a
whole
► The super mixin layer can be selected by one single expression
L<L1>
Prof. Uwe Aßmann, Design Patterns and Frameworks
class
class Layer
Layer <class
<class Super>
Super>
//
// The
The class
class Super
Super has
has nn inner
inner role
role classes
classes RoleSuper
RoleSuper1,, ..,
..,
1
//
// RoleSuper
RoleSupern n
extends
extends Super
Super {{
class
class Role
Role1 1 extends
extends Super.RoleSuper
Super.RoleSuper1 1 {{ ..
.. }}
..
..
class
class Role
Rolen extends
extends Super.RoleSuper
Super.RoleSupern {{ .. .. }}
n n
..
.. additional
additional classes..
classes..
}}
Example: A Graph Framework [Herrejon
Batory]
47
► Graph applications can be structured into mixin layers
► ConnectedOnDFTUndirected = CRL1<CL1<VN1<TL1<RL1>>>>>
► ConnectedOnBFTRevDirected = CRL1<CL1<VN2<TL2<RL2>>>>>
Traversal
Layer
TL1 DFT VertexDFT
TL2 BFT VertexBFT
Vertex Numbering
Layer
VN1 VertexNumber WorkspaceNumber
VertexReverse
VN2 WorkspaceNumber
Number
CycleLayer
ConnectedRegionLayer
49
The End