ADAPTIVE PROGRAMMING - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

ADAPTIVE PROGRAMMING

Description:

An extension of OOP using graph theory and formal languages to ... pattern is prefixed or appended to the generated code for the vertex or edge it specifies. ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 33
Provided by: se997
Category:

less

Transcript and Presenter's Notes

Title: ADAPTIVE PROGRAMMING


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

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.

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.

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

6
History
  • 1982 Hades (Hardware DEScription language by
    Niklaus Wirth at ETH Zurich)
  • 1982-1985 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)

7
History (Contd)
  • 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

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 !!!

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

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

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.

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.

13
Structure-Shy Behaviour
better program
ordinary program
structure-shy functionality
Components
structure
Aspect 1
synchronization
Aspect 2
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

15
Class Dictionary Graph
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

17
Class Dictionary Graph
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

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.

20
Example
UML CLASS DIAGRAM
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
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..
22
Traversal Strategy
from BusRoute through BusStop to Person
busStops
BusRoute
BusStopList
buses
one method for each red class
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
23
Traversal Strategy
from BusRoute bypassing Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
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..
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()
26
DJ Implementation
ClassGraph classGraph new ClassGraph() Travers
alGraph WPTraversal new TraversalGraph
(from BusRoute via BusStop to Person,
classGraph) int r aBusRoute.countPersons(WPTr
aversal)
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

28
Development Tools
  • DJ and AP Library
  • Demeter/C
  • DemeterJ
  • Demeter/StKlos
  • Dem/Perl5
  • Dem/C
  • Dem/CLOS
  • Demeter/Object Pascal

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

30
Conclusion
  • We covered
  • What Adaptive Programming is
  • Law of Demeter
  • Traversal Strategies
  • Propagation Patterns
  • Development Tools
  • Advantages of Adaptive Programming

31
References
  • http//www.ccs.neu.edu/research/demeter
  • Adaptive Object Oriented Software
  • Karl Liebher
  • Adaptive Programming
  • Mohammed G. Gauda Ted Herman

32
QUESTIONS
Write a Comment
User Comments (0)
About PowerShow.com