480 likes | 492 Views
Implement class definitions, unique parts, and single inheritance rule in your project. Write test cases early and flatten class graphs efficiently.
E N D
Tools Project COM 1205 Project Help
The 5 tasks • Each class must be defined in the class dictionary or must be imported. • No inheritance cycle. • Parts must be unique. • Single inheritance. • Terminal Buffer Rule. Project Help
Extreme programming • Important feature: • Write test cases early. Project Help
Parts must be unique A = <b> B <b> C. B = . C = . A : J | K common <b> B. J = <b> C. K = . Reduce second case to first case by flattening. Use above examples as test cases. Project Help
Parts must be unique:Reduction A : J | K common <b> B. J = <b> C. K = . Flattened: A : J | K. J = <b> C <b> B. K = <b> B. Project Help
Add additional task 6: Flatten Test case A : J | K common <b> B. J = <b> C. K = . Flattened: A : J | K. J = <b> C <b> B. K = <b> B. Project Help
Is Flatten useful elsewhere? Test case A : J | K common <b> B. J = <b1> C. K = String. Flattened: A : J | K. J = <b1> C <b> B. K = String <b> B. Project Help
Is Flatten useful elsewhere? Test case A : J | K common <b> B. J = <b> C. K = String. Flattened: A : J | K. J = <b> C <b> B. K = String <b> B. Terminal Buffer Rule Project Help
Parts must be unique • Delay flatten implementation and assume input is flat. We want to get a program running soon. • Phase 1: Implement “Parts must be unique” (PU) for flat class graphs with construction and alternation nodes and edges. Project Help
Parts must be unique • Which problem must be solved? • Find duplicates in a Java list. Search on google.com brought me to a book by John Zukowski: Mastering Java. He is a Northeastern CCS undergraduate alumnus. He describes that the set interface eliminates duplicates. His book is featured on the SUN site. Project Help
Parts must be unique • Proposal: add all the label elements of a class definition to a set and check if the set already contains each element. If so, have a violation. • Need an efficient imlementation of a set: HashSet: offers constant time performance for add and contains. Project Help
Some useful code • Set partNames = new HashSet(); • partNames.contains(aName); • partNames.add(aName); Project Help
Design for computing flattened class graph • compute_parts(TraversalGraph CA) • for each concrete class • find list of super classes • append parts of super classes to immediate parts • eliminate all parts from abstract classes. Project Help
Finding Superclasses • add auxiliary edges to class graph. • set them with one traversal. Project Help
Context Switch Project Help
XML Schema Evolution Write XMLized cds without any syntax. Rules for XMLizing: construction class A=… . to A=“<A>”…”</A>”. Motivation: instead of writing the program that translates, we write two class dictionaries or we even automatically generate them. Project Help
Approach object-equivalent same order • XMLCD1, XMLCD2, LL1CD1, LL1CD2 • LL1CD1 sublanguage of LL1CD2 • Algorithm: Input: s1 Output: s3 • o1 = Read(s1, XMLCD1) • s2 = Print(o1, LL1CD1) • o2 = Read(s2, LL1CD2) • s3 = Print(o2, XMLCD2) Project Help
Approach: Preprocessing • XMLS1, XMLS2 • Translate XMLS1 to XMLCD1 so that language is “preserved”. • Translate XMLS2 to XMLCD2 so that language is “preserved”. • ok. to have a slight change to documents Project Help
Slight Change <P> here we have any text </P> <P> (@ here we have any text @) </P> Cd: SomeClass = “<P>” Text </P>. Text is a terminal class like Ident defined in edu.neu.ccs.demeter Project Help
L1: A = B C. B : D | E common F. L2: A = X [Y] C. X = B [Z]. B : U | E | G common V [Z]. U = D. V = F. D = [A]. A class X not defined : X = . Ex 1:Consider two XMLized cds Project Help
L1: A = B C. B : D | E common F. L2: A = X [Y] C. X = B [Z]. B : U | E | G common V [Z]. U = D. V = F. D = [“a” A]. A class X not defined : X = “x”. L1 sublanguage L2 UnXMLize cds to avoid left recursion A X B U D A Project Help
lec7:90 class dictionaries (11 kinds) inductive nonleft-recursive 9 10 11 8 7 6 1 2 LL(1) 3 4 nonambiguous 5 Venn Diagram Project Help
L1: binary expressions E : S | C. S = int. C = Op <a1> E <a2> E. Op : A | M. L2: n-ary expressions E : S | C. S = int. C = Op <as> Es. Es = List(E). List(S) ~ {S}. Op : A | M. A class X not defined : X = . Ex 2: Two XMLized cds Project Help
L1: binary expressions E : S | C. S = int. C = Op “(“ <a1> E <a2> E”)”. Op : A | M. L2: n-ary expressions E : S | C. S = int. C = “(“Op <as> Es “)”. Es = List(E). List(S) ~ “(“ {S} “)”. Op : A | M. L1 a sublanguage of L2 A class X not defined : X = “x”. Ex 2: UnXMLized cds Project Help
Conjecture • Can we make both cds LL(1) by using A = [B]. -> A = [“bB” B “eB”]. A ~ {S}. -> A ~ “bA” {“bS” S “eS”} “eA”. Project Help
DJ partial evaluation cg.fetch(o, “from A via B to C”) -> o.get_x1().get_x2().get_x3(). … cg.traverse … generate code in a similar way as DemeterJ does. Project Help
Context switch • Multi-layer architecture similar to Demeter’s architecture. Project Help
UML language architecture • UML metamodel defines meaning of UML models • Defined in a metacircular manner, using a subset of UML to specify itself • UML metamodel bootstraps itself. Similar: • compiler compiles itself • grammar defines itself • class dictionary defines itself Project Help
4 layer metamodel architecture • UML metamodel one of the layers • Why four layers? • Proven architecture for complex models • Validates core constructs by using them to define themselves Project Help
Four layer architecture • meta-metamodel • language for specifying metamodels • metamodel • language for specifying models • model • language for specifying objects in some domain • user objects Project Help
Four levels • User Objects in running system • check run-time constraints • Model of System under design • specify run-time constraints • Meta-model • specify constraints on use of constructs in model • Meta-metamodel • data interchange between modeling tools Project Help
instance of Three layers of Demeter 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 text TP sentence Project Help
Icon Demeter Tiling Use as reminder for Demeter Tiling. CB OBCL TBOL TLOP TP Project Help
Example ??? Demeter Tiling CB OBCL TBOL TLOP TP Basket aBasket:Basket With respect to the project class dictionary as OB Project Help
Example Vertex (or Ident) Demeter Tiling CB OBCL TBOL TLOP TP Basket aBasket:Basket With respect to the project class dictionary as OB Project Help
Example ??? Demeter Tiling CB OBCL TBOL TLOP TP Regular_Syntax aRegular_Syntax:Regular_Syntax With respect to the project class dictionary as OB = OL Project Help
Example Vertex Demeter Tiling CB OBCL TBOL TLOP TP Regular_Syntax aRegular_Syntax:Regular_Syntax With respect to the project class dictionary as OB = OL Project Help
Example ??? Demeter Tiling CB OBCL TBOL TLOP TP Labeled = <label_name> Ident ... <b> With respect to the project class dictionary as OB = OL Project Help
Example Adjacency = <source> Vertex ... Demeter Tiling CB OBCL TBOL TLOP TP Labeled = <label_name> Ident ... <b> With respect to the project class dictionary as OB = OL Project Help
Example ??? Demeter Tiling CB OBCL TBOL TLOP TP Adjacency = <source> Vertex ... A = <b> B <b> B. With respect to the project class dictionary Project Help
Example Adjacency = <source> Vertex ... Demeter Tiling CB OBCL TBOL TLOP TP Adjacency = <source> Vertex ... A = <b> B <b> B. With respect to the project class dictionary Project Help
Strategy: From C1 to T o2:C2 o1:C1 declared type of o2 is C3=>C2 e go down e iff C1 <=.C C2 (=>.<=.C.=>)*.<=) T go down e iff C1 EI* EC C2 (EA*(EI* EC EA*)* EI*) T Project Help
go down e iff C1 <=.C C2 (=>.<=.C.=>)*.<=) T Example 1 strategy: {A -> B B -> C} Object graph Strategy s t :A A B C x1:X class graph S e1:Empty :R R A x2:X Empty B x c x c1:C X b c2:C BOpt c c3:C C Project Help
Agenda: Add to DJ • Add WandVisitor as a new subclass to Visitor. • In a WandVisitor visitor method activation is delayed until we are at a target. • What are the semantics? Project Help
WandVisitor example // where has source A and target C void someMethod(TraversalGraph where) { where.traverse(this, new WandVisitor(“A”,”C”) { void before(A a){print(a);} void before(B b){print(b);} void before(C c){print(c);} }); } Which methods will be executed when a C-object is visited? Not all As and Bs visited since last visit to a C-object? Project Help
Nov. 20, 2000 • Fail fast or multiple error messages? • Better several error messages. • Inheritance cycle checking. Is greatly simplified if we assume single inheritance. Project Help
Buffer Rules • Many problems of software engineering can be solved by another layer of indirection. Project Help
Applications of Traversal Strategies • Program Kinds in DJ • AdaptiveProgramTraditional(ClassGraph) • strategies are part of program: DemeterJ, Demeter/C++ • AdaptiveProgramDynamic(Strategies, ClassGraph) • strategies are a parameter. Even more adaptive. • AdaptiveProgram DJ_Typical (TraversalGraphs) • strategies are a parameter. Reuse traversal graphs. • AdaptiveProgramDJ(ObjectGraphSlices) • strategies are a parameter. Reuse traversal graph slices. Project Help