An analogy to Composition Filters Mehmet Aksit ([email protected] http:// trese . cs . utwente . nl TRESE Group, Department of Computer Science University of Twente Postbox 217, 7500 AE Enschede, The Netherlands TRESE e-tutorial series 03
Dec 30, 2015
An analogy toComposition Filters
Mehmet Aksit
([email protected] http://trese.cs.utwente.nl
TRESE Group, Department of Computer Science
University of Twente
Postbox 217, 7500 AE
Enschede, The Netherlands
TRESE e-tutorial series 03
2/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Copyright statement
You are not allowed to use part or whole of the tutorial material for any commercial purpose unless a written permission has been given by the TRESE group;
If you use part or whole of the material for a non-commercial purpose, then you have to make a reference to our web-site "taken from http://trese.cs.utwente.nl" and always include these two copyright conditions.
3/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Table of contents
An analogy
References
Filters
4/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Explain meplease what the
important characteristicsof Composition Filters
are?With pleasure!
I will try to explain you by making ananalogy between Composition Filters
and a real world example.
An analogy to Composition Filters
5/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Objective: taking a picture
Assume that wewant to take apicture of this
beautiful flower!
6/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Objective: taking a picture (cont’ed)
This is the camerawhat we have!
7/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Problem (1): camera cannot focus
This is thepicture we get!
d < min focus
Unfortunatelythe camera
cannotfocus on the
image.The camera is
too close!
8/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
We can builda new dedicatedcamera for this
problem
Sir!Can you build acamera for me
that cantake picturesfrom 2 cm.
A dedicated solution (1)
I am a cameramanufacturer!
$ $
With pleasurewe make a camerafor you, but:$$$$$
9/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Problem (2): light is not suitable
We solve thefocusing problem!
Lets turn the light on!
Unfortunatelythe light is not
suitable forthe film!
10/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
We can builda new dedicatedcamera for this
lighting!
We neednow a camera
which cantake pictures
with thislighting!
A dedicated solution (2)
No problem!
$ $
With pleasurewe make a camerafor you, but:$$$$$
11/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Problem (3): not sufficient light intensity
Unfortunately, sometimeswe do not have a
possibility of extra lighting.We must be able to
takea picture in
darkness. Do we needa special camera
which can intensify images?
12/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Each time a problemis experienced,
a new camera hadto be built.
This is too expensive!
Finding a dedicated solutionfor every problem is not
economical.
We must also be sure that
the solutionsare able to work
together.
Dedicated solutions
13/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Using modular extensions
May be we should not build adedicated camera each time we
have a new problem!Wait a minute! Why not use
a close up lens as an extension?
I have now a sharp picture. A modular extension is an
economical solution
14/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Using independent extensions
What if we experience a lightingproblem?
We can use a color filter! We solved the second
problemas well. These extensions
arerather independent from
each other!
15/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Open ended solutions
If we experience newproblems, such as
image intensification,we may add additional
extensions
16/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Well-defined semantics
Each extensionmust address a single concern
and have awell-definedsemantics!
extensionsfactory
Our extensionsare certified!
17/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Run-time solutions
I think there are differentkinds of photographers!Professionals would like
to choose the rightsolution whenever
they need to
“extensions at run-time”
18/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Compile-time solutions
Amateur photographers, however, may prefer
pre-installed solutions.For them, cameras must be
manufactured at thefactory!
“extensions at compile-time”
19/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Flexibility in selecting run-time or compile-time solutions
It must be easy toswitch between
run-timeor compile-time
solutions!
20/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Summary of the solution strategy
Modular extensions;
Independent extensions;
Open-ended solutions;
Well-defined semantics;
Switching between run-time or compile-time solutions.
Let me summarizethe characteristics
of my solution:
Actually, these are alsothe characteristics
of Composition Filters!
21/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Problems of current OO programs
If the requirementsevolve, current object-oriented programs may
require excessivenumber of
re-definitions.See for exampleour e-tutorial 01
“Evolution problems inObject Oriented Modeling”
22/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Evolution problems
It looks like that if softwareincorporates non-trivial code,for example, multiple views,
history sensitivity,synchronization, real-time,
constraints, dynamic behavior,it does not evolve easily.
23/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Filters are modular extensions
Instead of providingdedicated solutions
by modifyingclass descriptions, Composition Filters
offers modular extensions toclass abstractions
expressed in languages likeJava, C++ and Smalltalk.
a filter
A modularextensiona class
24/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Filters are independent extensions
In case more than one concernhas to be expressed, multiple
filters can be used.
Modular &independentextensions
a class
filter1
filter2
filter3
filter4
Each filter transforms incomingand/or outgoing messages
to/from object.
message
Filters are independent ofeach other!
25/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Filters are open-ended
New filter types can bedefined by programmers or
may be provided as libraries.However, filter definitions must
be carried out carefully.
26/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Well-defined semantics
Filters have well-definedsemantics.
For example we havedefined the following filters:
Concern Filter typePre-post conditions ErrorMultiple views ErrorDynamic inheritance DispatchDelegation DispatchLayered architecture MetaHistory sensitivity Meta + history classProtocol Meta + protocol classSynchronization WaitReal time RealTime
27/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Declarative specifications
Filters are expressed usingdeclarative specifications.
a filter specification
interpreter compiler
run-time solution compile-time solution
Filters can be interpreted,providing run-time solutions,
or they may be compiled,providing faster solutions.
28/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Monitoring
DynamicMail
LockingMail
These characteristics enhanceobject-oriented programs.
For example, in E-tutorial 01,I presented an evolution
scenario. Classes Email andUSViewMail were extended by
the following classes:
Warning2Mail
ORViewMail
USViewMail
EMailWarning2Mail,
LockingMail,DynamicMail
ORViewMail,
Here the concerns aremultiple views, history
sensitivity, synchronizationand dynamic protocols.
Evolution scenario
& monitoring
29/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
Evolution scenario
To know more about implementation of the scenariousing Composition Filters please refer to:
http://trese.cs.utwente.nl/courses/e_tutorials/evolution_cf.ppt
30/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
References
For more information please refer to:
1. Composition Filters homepage
2. Publications on Composition Filters
2. Implementations of Composition Filters
3. A historical perspective on Composition Filters
4. e-tutorial 01 “Evolution problems in OO modeling”
5. e-tutorial 02 “Solving the evolution problems using Composition Filters”
Do you havereferences?
31/31© 2001 TRESE Group, University of Twente
trese.cs.utwente.nl
More information?
If you want to have moreinformation, just send an email:
Mehmet Aksit: [email protected] Bergmans: [email protected]