Final Exam CSU 670 Fall 2003 Karl Lieberherr ================================================================== Remember: An UNKNOWN may have spaces and special characters in it or it maybe NOTHING. Question 1: =========== 4 UNKNOWNs, 10 points each: 40 points Consider the following class dictionary Histories (in file program.cd), program (in file program.beh) and input (in file program.input). Find the UNKNOWNs in the output. Also comment on the programming style of the main() method. Does it violate any of the software development principles. Give the principle(s) violated and explain where they are violated. Class dictionary Histories: =============================================================== import edu.neu.ccs.demeter.dj.*; Main = . Histories = PList(NewStrategy) PList(HistoryPcd). HistoryPcd = "history" "(" NewStrategy ")". NewStrategy : PrimitiveNewStrategy | CompositeNewStrategy. PrimitiveNewStrategy : Entry | Exit. Entry = "entry" "(" Pointcut ")". Exit = "exit" "(" Pointcut ")". Pointcut = "pointcut" PointcutName. CompositeNewStrategy : NamedNewStrategy | NamedNewStrategyRef | OrderedNewStrategy | OptionalNewStrategy | ZeroOrMoreNewStrategy. NamedNewStrategy : AbstractNewStrategy | ConcreteNewStrategy. AbstractNewStrategy = "abstract" [Modifiers] "pattern" NewStrategyName "(" Formals ")". ConcreteNewStrategy = "concrete" [Modifiers] "pattern" NewStrategyName "(" Formals ")" "::=" BarList(OrderedNewStrategy). NamedNewStrategyRef = "call" NewStrategyName "(" Actuals ")". OrderedNewStrategy = "ordered" PList(NewStrategy). OptionalNewStrategy = "[" NewStrategy "]". ZeroOrMoreNewStrategy = "{" NewStrategy "}". Modifiers = "modifiers". Formals = "formals". Actuals = "actuals". PList(S) ~ "(" {S} ")". List(S) ~ {S} . BarList(S) ~ "(" S {"|" S} ")". NewStrategyName = Ident. PointcutName = Ident "()". Program: ============================================================================ Main { {{ static ClassGraph cg; public static void main(String args[]) throws Exception { Histories m = Histories.parse(System.in); // m.display(); cg = new ClassGraph(true, false); System.out.println(); String whereToGo ; whereToGo = "from Histories via CompositeNewStrategy to NewStrategyName"; System.out.println(" Output of show() "); System.out.println(whereToGo); m.show(whereToGo); System.out.println(); whereToGo = "from Histories via OptionalNewStrategy to NewStrategyName"; System.out.println(" Output of show() "); System.out.println(whereToGo); m.show(whereToGo); System.out.println(); whereToGo = "from Histories via ConcreteNewStrategy to NewStrategyName"; System.out.println(" Output of show() "); System.out.println(whereToGo); m.show(whereToGo); System.out.println(); System.out.println(new TraversalGraph( "from Histories to NewStrategy", Main.cg)); System.out.println(); System.out.println(new TraversalGraph( "from Entry to Pointcut", Main.cg)); } }} } Histories { void display() to * (DisplayVisitor); } Histories { {{ void show(String whereToGo){ Visitor whatAndWhereToDo = new Visitor() { void before (NewStrategyName host) { System.out.println(host.get_ident()); } }; Main.cg.traverse(this, whereToGo, whatAndWhereToDo); } }} } INPUT: ========================================================== ( concrete pattern X (formals) ::= (ordered ( entry(pointcut A1()) call X(actuals) entry(pointcut A1()))) ) (history ( entry (pointcut A2()) ) history ( ordered ( call X(actuals) { entry (pointcut A3()) } ) ) history ( [ entry (pointcut A8()) ] ) ) OUTPUT: ========================================================= Output of show() from Histories via CompositeNewStrategy to NewStrategyName UNKNOWN1 Output of show() from Histories via OptionalNewStrategy to NewStrategyName UNKNOWN2 Output of show() from Histories via ConcreteNewStrategy to NewStrategyName UNKNOWN3 rest of output deleted Question 2: =============================================================== 5 UNKNOWNs, 6 points each: 30 points Extend the class dictionary Histories so that it will also accept the following input: ( concrete pattern X (formals) ::= (ordered ( entry(pointcut A1()) call X(actuals) entry(pointcut A1()))) ) (history ( entry (pointcut A2()) ) history ( ordered ( entry (pointcut A3()) entry (pointcut A3()) call X(actuals) [ entry (pointcut A3()) ] { entry (pointcut A3()) } ordered with bypassing ( entry (pointcut A5()) // source bypassing exit (pointcut A7()) entry (pointcut A9()) bypassing exit (pointcut A7()) { entry (pointcut A9()) } // zero or more entry (pointcut A9()) entry (pointcut A9()) bypassing exit (pointcut A7()) [ entry (pointcut A9()) ] // target is optional ) ) ) history ( [ entry (pointcut A8()) ] ) ) Find the UNKNOWNs in the class dictionary Histories2 below. Histories2 contains all classes that class dictionary Histories contains. // Class dictionary Histories2 Main = . Histories = PList(NewStrategy) PList(HistoryPcd). HistoryPcd = "history" "(" NewStrategy ")". NewStrategy : PrimitiveNewStrategy | CompositeNewStrategy. PrimitiveNewStrategy : Entry | Exit. Entry = "entry" "(" Pointcut ")". Exit = "exit" "(" Pointcut ")". Pointcut = "pointcut" PointcutName. CompositeNewStrategy : NamedNewStrategy | NamedNewStrategyRef | OrderedNewStrategy | // new UNKNOWN1 | OptionalNewStrategy | ZeroOrMoreNewStrategy. NamedNewStrategy : AbstractNewStrategy | ConcreteNewStrategy. AbstractNewStrategy = "abstract" [Modifiers] "pattern" NewStrategyName "(" Formals ")". ConcreteNewStrategy = "concrete" [Modifiers] "pattern" NewStrategyName "(" Formals ")" "::=" BarList(OrderedNewStrategy). NamedNewStrategyRef = "call" NewStrategyName "(" Actuals ")". OrderedNewStrategy = "ordered" PList(NewStrategy). //new OrderedWithBypassingNewStrategy = "ordered with bypassing" UNKNOWN2 NewStrategy UNKNOWN3. BypassingNewStrategy = UNKNOWN4 PrimitiveNewStrategy UNKNOWN5 NewStrategy. OptionalNewStrategy = "[" NewStrategy "]". ZeroOrMoreNewStrategy = "{" NewStrategy "}". Modifiers = "modifiers". Formals = "formals". Actuals = "actuals". PList(S) ~ "(" {S} ")". List(S) ~ {S} . BarList(S) ~ "(" S {"|" S} ")". NewStrategyName = Ident. PointcutName = Ident "()". Question 3: ============================================================= 15 points for each list: 30 points Consider the class dictionary Histories from question 1: For the traversal strategies "from Histories to NewStrategy" "from Entry to Pointcut" list in alphabetical order the classes that will be highlighted in the UML class diagram for Histories. This refers to your project which highlights all the classes that are involved in the traversal. Two separate alphabetically sorted lists please in UNKNOWN1 and 2. Question 4: Software development problem: ================================================================ 30 points. Assume you have a class dictionary C1 with tokens x1, x2, x3, ... You want to change the class dictionary C1 to a class dictionary C2 so that each token is modified, e.g., appended with letter y. So if the class dictionary had tokens "basket", "fruit", ")" it will have tokens "baskety", "fruity", ")y". For example: C1 is: A = "a" B C. B = "b". C = "c". C2 is: A = "ay" B C. B = "by". C = "cy". The input string "a b c" is translated to "ay by cy". Use DemeterJ to develop a translator from the language of class dictionary C1 to the language of class dictionary C2. Describe your solution in UNKNOWN1. The solution is very simple and involves using DemeterJ twice: once for C1 and once for C2. Question 5: ================================================================= 20 points Consider the class dictionary Histories from question 1 that accepts the following input: ( concrete pattern X (formals) ::= (ordered ( entry(pointcut A1()) call X(actuals) entry(pointcut A1()))) ) (history ( entry (pointcut A2()) ) history ( ordered ( call X(actuals) { entry (pointcut A3()) } ) ) history ( [ entry (pointcut A8()) ] ) ) Change the class dictionary so that it also accepts the following input. The change is that formal parameters are now a list of pairs, the first element a type name, the second element a variable name. ( concrete pattern X (X x, Y y) ::= (ordered ( entry(pointcut A1()) call X(actuals) entry(pointcut A1()))) concrete pattern X (X x) ::= (ordered ( entry(pointcut A1()) call X(actuals) entry(pointcut A1()))) concrete pattern X ( ) ::= (ordered ( entry(pointcut A1()) call X(actuals) entry(pointcut A1()))) ) (history ( entry (pointcut A2()) ) history ( ordered ( call X(actuals) { entry (pointcut A3()) } ) ) history ( [ entry (pointcut A8()) ] ) ) Give in UNKNOWN1 the detailed changes to the class dictionary. Follow the terminal buffer rule. Question 6: ============================================================ 4 UNKNOWNs, 4 points each: 16 points The following text describes the Eclipse design. Find the UNKNOWNs. Each plug-in has a UNKNOWN1 file declaring its interconnections to other plug-ins. The interconnection model is simple: a plug-in declares any number of named UNKNOWN2, and any number of UNKNOWN3 to one or more UNKNOWN4 in other plug-ins. HAPPY HOLIDAYS