-------------------------------------------------------------------------- Software Design and Development Winter 1997 COM1205 Karl Lieberherr --------------------------------------------------------------------------- Midterm --------------------------------------------------------------------------- Open book and open notes. Question 1: 20 UNKNOWNs, 1 point each: 20 points Question 2: 2 unknowns, 20 points each: 40 points Question 3: 18 UNKNOWNS, 3 points each: 54 points Question 4: 25 UNKNOWNs, 3 points each: 75 points TOTAL: 189 /proj/asl/lieber/java/new-java-envs/t1/for-www To make the grading easier, please put your values for the unknowns on the enclosed answer sheet. THE GAME OF REDUNDANCY AND UNKNOWNS ----------------------------------- Most of the questions in this exam ask you to determine unknowns of the form UNKNOWN1, UNKNOWN2, ... This makes it easier for you to answer the questions, since you get extra context information. Yet you need to master the behavioral objectives of the course to answer the questions. Guessing an answer is not a successful strategy and therefore a "game of redundancy" test is more interesting than a multiple choice test. The questions have the following pattern: I show you several artifacts which are related by the theory of object-oriented design and programming. Because of the dependencies between the artifacts, some of the information is redundant and can be recovered from the context by applying the objectives covered in the course. The information which you should discover is marked UNKNOWNx. If an unknown is not uniquely determined, mark the answer with *CHOICE*. An unknown may be anything, e.g., a number, an identifier, a character, two identifiers with a blank between them, a string etc. If an unknown is the empty string, give NOTHING as answer, e.g., UNKNOWN = NOTHING. Example: 5 + UNKNOWN1 = 8 UNKNOWN1 = 3 --------------- UNKNOWN2 * UNKNOWN3 = 20 UNKNOWN2 = 4 *CHOICE* UNKNOWN3 = 5 *CHOICE* At the beginning of a question we give the number of points per unknown. Question 1: 20 UNKNOWNs, 1 point each: 20 points This question is about object serialization: taking an object and producing a sentence, using the visitor design pattern. It covers the following behavioral objectives of chapter 14 in the AP-book: Class dictionary textual representation (31) Printing (34) Parsing (38) Propagation operator (59) It covers the design patterns: Structure-shy Traversal Structure-shy Object (covered by the objectives above) Selective Visitor Note: The class dictionary below defines a different notation than Demeter/Java uses. Also, the PrintingVisitor defines a printing function which is different than the usual one. Consider the following class dictionary called TraversalPP: TraversalPP = "traversal-pp" ClassName FunctionName Args Body. Body = "{" Initialize Traversal VisitorMethods "}". Initialize = "initialize" JavaCode. Traversal : Simple | Compound. Simple = [ From ] Constraints To. Compound = Op Traversals. Op : Join. Join = "join". From = "from" ClassName. To = "to" ClassName. Constraint = [ Bypassing] Through. Bypassing = "bypassing" Edges. Through = "through" Edges. Edge = "->" ClassName LabelName ClassName. Arg = JavaTypeName Variable. VisitorMethod : Before | After *common* ClassNames JavaCode. Before = "before". After = "after". // Terminal-Buffer rule ClassName = Ident. JavaTypeName = Ident. Variable = Ident. LabelName = Ident. FunctionName = Ident. JavaCode = Text. // Repetition-Buffer rule Args = "(" [ CList(Arg) ] ")". ClassNames = "{" CList(ClassName) "}". VisitorMethods = NList(VisitorMethod) . Traversals = "(" CList(Traversal) ")". Edges = NList(Edge). Constraints = List(Constraint). // Repetition classes CList(S) ~ S {"," S}. NList(S) ~ S {S}. List(S) ~ {S}. Main = .