Midterm Review CSU 670 Spring 2004
AP Late binding of data structures Programming without accidental data structure details yet handling all those details on demand without program change
Concepts needed (DJ classes) ClassGraph Strategy Visitor ObjectGraph TraversalGraph (efficiency) ObjectGraphSlice (efficiency)
Strategy ClassGraph ObjectGraph Adaptive Programming is use-case based Bold names refer to DJ classes. is use-case based abstraction of ClassGraph New: abstractions of class diagrams notice affinity to design patterns: some of them also talk about families of class structures explain strategies defines family of ObjectGraph
Strategy ObjectGraph ObjectGraphSlice Adaptive Programming defines traversals of ObjectGraph plus Strategy defines explain strategies ObjectGraphSlice
Strategy Visitor Adaptive Programming guides and informs explain strategies Visitor
Software Design and Development with DJ (very brief) Functional decomposition into generic behavior Decomposition into methods Decomposition into formal traversal strategies Decomposition into visitors Adaptation of generic behavior Identify class graph Identify traversal strategies
Definition: Class Graph A class graph is a directed graph with a partial order on the nodes. We write c1 -> c2 for the edges (construction edges) and c1 <= c2 for the order (inheritance edges -- c1 is a subclass of c2). We write => for the inverse of <=.
Relations We think of directed graphs as relations. Write C(c1,c2) or c1 C c2 for edge from c1 to c2 in C. Composition of relations by . E.g., x (R.S) z iff there is a y such that xRy and ySz. R* is the reflective transitive closure of a relation R.
Strategy: From X1 to T o1:X1 o2:X2 declared type of target of e is X3 =>X2 e go down e iff X1 <=.e X3 =>.(<=.C.=>)*.<=) T if only construction edges: go down e iff X1 e X3 C* T
z Strategy S -> T x X1 Y1 Z1 y S X2 Y2 Z2 T t X3 Y3 Z3 x y z t s1:S x31:X3 y31:Y3 z31:Z3 t1:T go down e iff S <=.C X1 =>.(<=.C.=>)*.<=) T
z Strategy S -> T x X1 Y1 Z1 y S X2 Y2 Z2 T t X3 Y3 Z3 x y z t s1:S x31:X3 y31:Y3 z31:Z3 t1:T go down e iff S <=.C X1 =>.(<=.C.=>)*.<=) T
z Strategy S -> T x X1 Y1 Z1 y S X2 Y2 Z2 T t X3 Y3 Z3 x y z t s1:S x31:X3 y31:Y3 z31:Z3 t1:T <=,=> not used go down e iff S <=.C X1 =>.(<=.C.=><=.C.=><=.C=>).<=) T
Example strategy A -> T T -> D a1:A 0..1 :D r1:R X 0..1 B c1:C s1:S D A C s2:S t1:T 0..1 r2:R object graph R S T 0..1 c2:C class graph d2:D go down e iff A <=.C R =>.(<=.C.=>)*.<=) T
Example 2 S = from BusRoute through Bus to Person busStops BusRoute BusStopList buses 0..* NGasPowered BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* DieselPowered
Example 2 OG : BR BL DP PL P OG’: BR BL B PL P SG : BR B P Only node paths shown for space reasons Route1:BusRoute BusList buses busStops :BusStopList Bus15:DieselPowered passengers CentralSquare:BusStop waiting :PersonList :PersonList Joan:Person Paul:Person Seema:Person Eric:Person S = from BusRoute through Bus to Person
Example 3 OG : BR BL OG’: BR BL SG : BR Only node paths shown for space reasons early termination Route1:BusRoute BusList buses busStops :BusStopList Bus15:DieselPowered passengers CentralSquare:BusStop waiting :PersonList :PersonList Joan:Person Paul:Person Seema:Person Eric:Person S = from BusRoute via NGasPowered to Person
A simple view of traversals When a traversal reaches a target node in the object graph, the path traversed from the source, with suitable substitution of subclasses by superclasses, must be an expansion of an s-t path in the strategy graph. s is the source and t is the target of the strategy. Each edge in the strategy graph corresponds to at least one edge in the object graph.
A simple view of traversals When a traversal reaches a final node in the object graph without being at a target, the path traversed from the source, with suitable substitution of subclasses by superclasses, must be a prefix of an expansion of an s-t path in the strategy graph. The prefix is the longest prefix such that there is still a possibility of success as determined by the class graph.
Object Graph Slice The object graph slice starting with o1 is the slice built by following the edges selected by the path regular expression starting at o1 and continuing until every path terminates (at an object of type t or if it terminates prematurely). go down e iff X1 <=.e X3 =>.(<=.C.=>)*.<=) T
Strategy definition: embedded, positive strategies Given a graph G, a strategy graph S of G is any subgraph of the transitive closure of G. The transitive closure of G=(V,E) is the graph G*=(V,E*), where E*={(v,w): there is a path from vertex v to vertex w in G}.
Transitive Closure busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..*
Strategy graph and base graph are directed graphs Key concepts Strategy graph S with source s and target t of a base graph G. Nodes(S) subset Nodes(G) (Embedded strategy graph). A path p is an expansion of path p’ if p’ can be obtained by deleting some elements from p.
class dictionaries (11 kinds) inductive nonleft-recursive 9 10 11 8 7 6 1 2 LL(1) 3 1: ideal case 2: JavaCC does not complain (Oct. 30 1997). Grammar contains useless symbols. Ok if we don’t want to parse but forces cyclic objects. 4 nonambiguous 5 Venn Diagram 12/30/2018 AOO / Demeter
Patterns Patterns Structure-shy Traversal Selective Visitor Structure-shy Object Class Graph Growth Plan Pattern
Three layers of Demeter instance of defines classes Demeter behavior and aspect files B: metamodel L: model P: user objects CB your behavior and aspect files CL metamodel OB classes model OL TB user object OP a class dictionary for class dictionaries objects TL class dictionary TP text sentence
Icon Use as reminder for Demeter Tiling. Demeter Tiling CB OB CL TB OL TL OP TP
Example ??? Demeter Tiling CB OB CL Basket TB OL TL OP TP aBasket:Basket With respect to the project class dictionary as OB
Example Vertex (or Ident) Demeter Tiling CB OB CL Basket TB OL TL OP TP Basket aBasket:Basket With respect to the project class dictionary as OB
Example ??? Demeter Tiling CB OB CL Regular_Syntax TB OL TL OP TP aRegular_Syntax:Regular_Syntax With respect to the project class dictionary as OB = OL
Example Vertex Demeter Tiling CB OB CL Regular_Syntax TB OL TL OP TP aRegular_Syntax:Regular_Syntax With respect to the project class dictionary as OB = OL
Example ??? Demeter Tiling CB OB CL TB OL TL OP TP Labeled = <label_name> Ident ... <b> With respect to the project class dictionary as OB = OL
Example Adjacency = <source> Vertex ... Demeter Tiling CB OB CL TB OL TL OP TP Labeled = <label_name> Ident ... <b> With respect to the project class dictionary as OB = OL
Example ??? Demeter Tiling CB OB CL TB OL TL OP TP Adjacency = <source> Vertex ... A = <b> B <b> B. With respect to the project class dictionary
Example Adjacency = <source> Vertex ... Demeter Tiling CB OB CL TB OL TL OP TP Adjacency = <source> Vertex ... A = <b> B <b> B. With respect to the project class dictionary
Lightweight Software Development Method Extreme Programming lots of testing, write test cases early incremental development pair programming
UML class diagrams object diagrams