Download presentation
Presentation is loading. Please wait.
Published byStella Elliott Modified over 6 years ago
1
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005
2
Outline What is Adaptive Programming? Law of Demeter
Structure-Shy Behavior (Traversal Strategy) Propagation Patterns Example Development Tools Conclusion November 19, 2018 Adaptive Programming
3
What is Adaptive Programming?
Changes its behavior according to its environment Encapsulates class hierarchies using traversal strategies and visitors An extension of OOP using graph theory and formal languages to further abstract collaborating classes and generate a family of programs from a common architectural graph. November 19, 2018 Adaptive Programming
4
What is Adaptive Programming?
Aspects or components use graphs which are described by traversal strategies. A traversal strategy defines traversals of graphs without referring to the details. Adaptive programming is aspect-oriented programming with traversal strategies. November 19, 2018 Adaptive Programming
5
What is Adaptive Programming?
Adapts automatically to changing context Class structures are described partially Behavior is not implemented exhaustively Methods are implemented when they are needed November 19, 2018 Adaptive Programming
6
History 1982: Hades (Hardware DEScription language by Niklaus Wirth at ETH Zurich) : Zeus (brother of Hades, a silicon compilation language developed at Princeton University/MIT) 1985-Present: Demeter (sister of Zeus, used to implement Zeus, started at GTE Labs) November 19, 2018 Adaptive Programming
7
History (Cont’d) 1990: First traversal specifications
1995: Separation of Concerns by Huersch and Lopes started “untangling” movement. Collaboration with Xerox PARC began 1996: Gregor Kiczales and his group further develop Aspect Oriented Programming November 19, 2018 Adaptive Programming
8
Law of Demeter originally formulated as a style rule for designing object-oriented systems Each unit should have only limited knowledge about other units: only units "closely" related to the current unit. each unit should only talk to its friends DO NOT TALK TO STRANGERS !!! November 19, 2018 Adaptive Programming
9
Law of Demeter More specific case of Low Coupling Principle The motivation for the Law of Demeter is to control information overload When writing a method, one should not hardwire the details of the class structure into that method November 19, 2018 Adaptive Programming
10
Structure-Shy Behavior (Traversal Strategy)
Programming is shy if it hides details of other concerns it cuts across Gathers the code describing the traversal in one place with minimal dependency on the class structure Compliant with Law of Demeter November 19, 2018 Adaptive Programming
11
Structure-Shy Behavior (Traversal Strategy)
Allows one to specify strategies that ignore certain parts of the concrete structure Lowers the coupling of code from the concrete structure Lessens the dependency of code changes when structure changes Idea is to capture the essential structure and ignore the rest. November 19, 2018 Adaptive Programming
12
Structure-Shy Behavior
An implementation of a concern C1 is C2-shy if: The C1 implementation relies only on minimal information of C2 implementations. The C1 implementation can adapt to small changes in C2 implementations. The C1 implementation is loosely coupled with C2 implementations. The C1 implementation can work with C2’ , C2’’ , C2’’’ which are close or similar to C2 implementations. November 19, 2018 Adaptive Programming
13
Structure-Shy Behaviour
ordinary program better program structure-shy functionality Components structure Aspect 1 avoid tangled programs AOP synchronization Aspect 2 November 19, 2018 Adaptive Programming
14
Propagation Patterns Adaptive program is specified using a collection of propagation patterns. Propagation patterns specify a set of related constraints in the adaptive program Given a customizing Class Dictionary Graph, a propagation pattern produces an OO program denoted by the adaptive program it specifies November 19, 2018 Adaptive Programming
15
Class Dictionary Graph
November 19, 2018 Adaptive Programming
16
Class Dictionary Graph
Vertices Construction Vertex : Abstraction of a classs definition Alternation Vertex: Define union classes Repetition Vertex : Represents lists Edges Alternation Edges: Represents alternative relationship Construction Edges: Represents parts November 19, 2018 Adaptive Programming
17
Class Dictionary Graph
November 19, 2018 Adaptive Programming
18
Propagation Graph Customize a propagation pattern with class dictionary graph, its traversal specifications induce a set of paths Propagation Graph: Sum up the total salary of officers November 19, 2018 Adaptive Programming
19
Propagation Graph – Code Generation
For each vertex in the propagation graph: A method is created with the signature given by the operation specification in the propagation pattern. The body for this method contains as many calls as the given vertex has outgoing construction edges in the propagation graph. Each call is made to the method with the same signature attached to the vertex target of the corresponding construction edge. Finally, each wrapper code fragment in the propagation pattern is prefixed or appended to the generated code for the vertex or edge it specifies. November 19, 2018 Adaptive Programming
20
Example busStops BusRoute BusStopList buses 0..* BusStop BusList
UML CLASS DIAGRAM busStops BusRoute BusStopList buses 0..* BusStop BusList Example for developing strategies and writing adaptive programs waiting 0..* passengers Bus PersonList Person 0..* November 19, 2018 Adaptive Programming
21
Collaborating Classes
find all people waiting at any bus stop on a bus route busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* November 19, 2018 Adaptive Programming
22
Traversal Strategy from BusRoute through BusStop to Person busStops
BusStopList buses one method for each red class 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* November 19, 2018 Adaptive Programming
23
Traversal Strategy from BusRoute bypassing Bus to Person busStops
BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* November 19, 2018 Adaptive Programming
24
Robustness of Strategy
from BusRoute through BusStop to Person villages BusRoute BusStopList busses VillageList busStops 0..* 0..* BusStop BusList Village waiting 0..* passengers Bus PersonList Person 0..* November 19, 2018 Adaptive Programming
25
DJ: Implementation class BusRoute {
int countPersons(TraversalGraph WP) { Integer result = (Integer)WP.traverse(this, new Visitor() { int r ; public void before(Person host){ r++; } public void start() { r = 0;} public Object getReturnValue() {return new Integer ( r);} }); return result.intValue(); } November 19, 2018 Adaptive Programming
26
DJ: Implementation ClassGraph classGraph = new ClassGraph();
TraversalGraph WPTraversal = new TraversalGraph (“from BusRoute via BusStop to Person”, classGraph); int r = aBusRoute.countPersons(WPTraversal); November 19, 2018 Adaptive Programming
27
Taxi driver analogy Streets and intersections correspond to class graph Traversal strategy determines how the taxi will navigate through the streets You can take pictures before and after intersections You can veto sub traversals November 19, 2018 Adaptive Programming
28
Development Tools DJ and AP Library Demeter/C++ DemeterJ
Demeter/StKlos Dem/Perl5 Dem/C++ Dem/CLOS Demeter/Object Pascal this technology is catching on November 19, 2018 Adaptive Programming
29
Advantages of AP Focus on the essence of a problem to be solved and leads to simpler and shorter than conventional object-oriented programs. Promote reuse. Robust to changes Design matches program More understandable code Improved productivity November 19, 2018 Adaptive Programming
30
Conclusion We covered What Adaptive Programming is Law of Demeter
Traversal Strategies Propagation Patterns Development Tools Advantages of Adaptive Programming November 19, 2018 Adaptive Programming
31
References http://www.ccs.neu.edu/research/demeter
Adaptive Object Oriented Software Karl Liebher Adaptive Programming Mohammed G. Gauda – Ted Herman November 19, 2018 Adaptive Programming
32
QUESTIONS November 19, 2018 Adaptive Programming
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.