-------------------------------------------------------------------------- Object-Oriented Systems Fall 1993 COM 3360 --------------------------------------------------------------------------- Final 244 points total QUESTION 1: 41 UNKNOWNs, 2 points each: 82 points. QUESTION 2: 21 UNKNOWNs, 2 points each: 42 points. QUESTION 3: 1 UNKNOWN, 15 points. QUESTION 4: 26 UNKNOWNs, 3 points each: 78 points. QUESTION 5: 9 UNKNOWNS, 3 points each: 27 points --------------------------------------------------------------------------- Open book and open notes. 2 hour exam. To make the grading easier, please put your values for the unknowns on the enclosed answer sheet. ==================================== WELCOME TO THE CLUB OF THE TOP OBJECT-ORIENTED SOFTWARE DEVELOPERS. YOU CAN NOW DEVELOP APPLICATIONS BETTER AND FASTER THAN MANY PROFESSIONALS WHO HAVE SEVERAL YEARS OF OO EXPERIENCE. I AM INTERESTED IN FOLLOWING YOUR PROGRESS IN APPLYING ADAPTIVE SOFTWARE TECHNOLOGY. PLEASE HELP SPREAD THE WORD AND LET ME KNOW IF YOUR COMPANY COULD BENEFIT FROM THE AVAILABILITY OF THE DEMETER TOOLS/C++. THE TOOLS ARE EASY TO PORT TO YOUR PLATFORM. ==================================== 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. All the questions (except 5) use the following pp, called PP: *operation* void f() *traverse* *from* A *to* Z ///////////////////////////////////////// *carry* *in* B* b_broadcast *along* *from* B *to* Y *at* B b_broadcast = (@ this; @) *wrapper* Y *prefix* (@ cout << endl << this << " = Y-object contained in " << b_broadcast << endl; @) ///////////////////////////////////////// *carry* *in* Y_List* y_list *along* *from* B *to* Y *at* B y_list = (@ new Y_List(); @) *wrapper* Y *prefix* (@ y_list -> append(this); @) *wrapper* B *suffix* (@ cout << endl << " collected Y_List in B is: " << y_list << endl; @) ///////////////////////////////////////// *carry* *out* int count_condensed *along* *from* C *to* X *at* X count_condensed = (@ count_condensed + 1; @) *wrapper* C *prefix* (@ count_condensed = 0; @) *suffix* (@ cout << endl << "count of X in C " << count_condensed << endl; @) *wrapper* Z *prefix* (@ cout << endl << "Z-object = " << this << endl; @) QUESTION 1: ===================================================================== 41 UNKNOWNs, 2 points each: 82 points. Consider the following class dictionary: A = "b" List(B). B : C | Q | R. Q = Y. R = K. K : I | J *common* X Y. I = . J = . C = "x" List(X). X : Y. Y = "y" Z. Z = "z". Dummy = List(Y). List(S) ~ "(" S {"," S} ")". After applying cd-navigate: 1 A = "b" List(B). 2 B : C | Q | R. 3 Q = Y. 4 R = K. 5 K : I | J *common* X Y. 6 I = . 7 J = . 8 C = "x" List(X). 9 X : Y. 10 Y = "y" Z. 11 Z = "z". 12 13 Dummy = List(Y). 14 List(S) ~ "(" S {"," S} ")". A :1 B :2 1 C :8 2 Dummy :13 I :6 5 J :7 5 K :5 4 List :14 1 8 13 Q :3 2 R :4 2 X :9 5 8 Y :10 3 5 9 13 Z :11 10 Find the UNKNOWNs in the following traversal and transportation graphs: Traversal directive: *from* { A } *to* { Z } Transportation directive: *from* { B } *to* { Y } Propagation graph for transportation: B : UNKNOWN1 . UNKNOWN2 = UNKNOWN3 . R = UNKNOWN4 . UNKNOWN5 : UNKNOWN6 . I = (*inherits* K ) . J = (*inherits* K ) . C = < xs > X_List . X : UNKNOWN7 . Y = . UNKNOWN8 ~ UNKNOWN9 . Traversal directive: *from* { A } *to* { Z } Transportation directive: *from* { C } *to* { X } Propagation graph for transportation: UNKNOWN10 = UNKNOWN11 . UNKNOWN12 : UNKNOWN13 . UNKNOWN14 ~ UNKNOWN15 . Traversal directive: *from* { A } *to* { Z } Propagation graph for traversal: A = UNKNOWN16 . B : UNKNOWN17 . Q = UNKNOWN18 . UNKNOWN19 = UNKNOWN20 . K : UNKNOWN21 . I = . J = . C = UNKNOWN22 . X : UNKNOWN23 . Y = UNKNOWN24 . Z = . UNKNOWN25 ~ UNKNOWN26 . X_List ~ X { X } . Consider the following input object : A ( < bs > : B_List { : C ( < xs > : X_List { : Y ( < z > : Z ( ) ) } ) , : C ( < xs > : X_List { : Y ( < z > : Z ( ) ) , : Y ( < z > : Z ( ) ) } ) } ) Its corresponding sentence form is: b ( UNKNOWN27 ( UNKNOWN28 ) , x ( UNKNOWN29 ) ) It produces the following output: >> void A::f() >> void B_List::f() >> void C::f() >> void C::f(B* b_broadcast,Y_List* y_list) >> void X_List::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list) UNKNOWN30 = Y-object contained in UNKNOWN31 >> void Z::f() Z-object = UNKNOWN32 << void Z::f() << void Y::f(B* b_broadcast,Y_List* y_list) << void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) << void X_List::f(B* b_broadcast,Y_List* y_list,int& count_condensed) collected Y_List in B is: UNKNOWN33 count of X in C UNKNOWN34 << void C::f(B* b_broadcast,Y_List* y_list) << void C::f() >> void C::f() >> void C::f(B* b_broadcast,Y_List* y_list) >> void X_List::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list) UNKNOWN35 = Y-object contained in UNKNOWN36 >> void Z::f() Z-object = UNKNOWN37 << void Z::f() << void Y::f(B* b_broadcast,Y_List* y_list) << void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list) UNKNOWN38 = Y-object contained in UNKNOWN39 >> void Z::f() Z-object = z << void Z::f() << void Y::f(B* b_broadcast,Y_List* y_list) << void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) << void X_List::f(B* b_broadcast,Y_List* y_list,int& count_condensed) collected Y_List in B is: UNKNOWN40 count of X in C UNKNOWN41 << void C::f(B* b_broadcast,Y_List* y_list) << void C::f() << void B_List::f() << void A::f() QUESTION 2: ========================================================= 21 UNKNOWNs, 2 points each: 42 points Consider the following cd and the propagation pattern PP. A = "b" B. B : C. C = "x" X. X : Y. Y = "y" Z. Z = "z". Dummy = List(Y). List(S) ~ {S}. The resulting program is run on input: b x y z Find the UNKNOWNs in the following: The object graph for the input: : A ( < b > : C ( < x > : Y ( < z > : Z ( ) ) ) ) The trace: >> void A::f() >> void C::f() >> void C::f(B* b_broadcast,Y_List* y_list) >> void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) >> void Y::f(B* b_broadcast,Y_List* y_list) UNKNOWN1 = Y-object contained in UNKNOWN2 >> void Z::f() Z-object = UNKNOWN3 << void Z::f() << void Y::f(B* b_broadcast,Y_List* y_list) << void Y::f(B* b_broadcast,Y_List* y_list,int& count_condensed) collected Y_List in B is: UNKNOWN4 count of X in C UNKNOWN5 << void C::f(B* b_broadcast,Y_List* y_list) << void C::f() << void A::f() The C++ program: void A::f( ) { // outgoing calls b ->f( ); } // B is alternation class void B::f( ) { } void C::f( ) { // variables for carrying in and out UNKNOWN6 ; UNKNOWN7* y_list ; // assignments for carrying in UNKNOWN8 ; y_list = new UNKNOWN9(); ; this->f( UNKNOWN10 , y_list );} void C::f( B* UNKNOWN11,Y_List* UNKNOWN12 ) { // variables for carrying in and out UNKNOWN13 ; // prefix blocks UNKNOWN14 = 0; // outgoing calls x ->f( UNKNOWN15 , y_list , UNKNOWN16 ); // suffix blocks cout << endl << " collected Y_List in B is: " << UNKNOWN17 << endl; UNKNOWN18; } // X is alternation class void X::f( B* b_broadcast,Y_List* y_list,int& count_condensed ) { } void Y::f( B* b_broadcast,Y_List* y_list,int& count_condensed ) { this->f( UNKNOWN19 ); // assignments for carrying out UNKNOWN20 ; } void X::f( B* b_broadcast,Y_List* y_list ) { } void Y::f( B* b_broadcast,Y_List* y_list ) { // prefix blocks UNKNOWN21 ; cout << endl << this << " = Y-object contained in " << b_broadcast << endl; // outgoing calls z ->f( ); } void Z::f( ) { // prefix blocks cout << endl << "Z-object = " << this << endl; } QUESTION 3: =============================== 1 UNKNOWN, 15 points. The propagation pattern is PP and consider the customizer: ///////// A = "b" B. B : C. C = "x" X Y Z. X = "x". Y = "y". Z = "z". Dummy = List(Y). List(S) ~ {S}. ///////// When evaluating the transportation directive *from* B *to* Y in the traversal graph determined by *from* A *to* Z the propagation pattern compiler reports: propagate: evaluating transportation directives ... propagate: error : unavailable class :'UNKNOWN' Give the unknown and one sentence of explanation. QUESTION 4: ================================================================ 26 UNKNOWNs, 3 points each: 78 points. Find the UNKNOWNs in the following artifacts. Consider the class dictionary A UNKNOWN1. B UNKNOWN2. C UNKNOWN3. X UNKNOWN4. Y UNKNOWN5. Z UNKNOWN6. Dummy = List(Y). List(S) ~ "(" S {"," S} ")". This cd is used to customize the adaptive program PP and it is run on the following object: : A ( < UNKNOWN7 > : B ( < UNKNOWN8 > : C ( < UNKNOWN9 > : X ( < UNKNOWN10 > : Y ( < UNKNOWN11 > : Z ( ) ) ) ) ) ) The representation of this object as a sentence is: b c x y z z The program produces the following trace: >> void A::f() >> void B::f() >> void C::f(UNKNOWN12 ,Y_List* y_list) >> void X::f( UNKNOWN13 ) >> void Y::f(B* b_broadcast,Y_List* y_list) z z = Y-object contained in c x y z z >> void Z::f() Z-object = z << void Z::f() << void Y::f(B* b_broadcast,Y_List* y_list) << void X::f( UNKNOWN14 ) count of X in C 1 << void C::f(UNKNOWN15,Y_List* y_list) collected Y_List in B is: ( z z ) << void B::f() << void A::f() The C++ program produced by the cd and the adaptive program is: void A::f UNKNOWN16 { // outgoing calls b ->f( UNKNOWN17 ); } void B::f UNKNOWN18 { B* b_broadcast ; Y_List* y_list ; // assignments for carrying in b_broadcast = this; ; y_list = new Y_List(); ; // outgoing calls c ->f( UNKNOWN19 ); // suffix blocks cout << endl << " collected Y_List in B is: " << y_list << endl; } void C::f UNKNOWN20 { // variables for carrying in and out int count_condensed ; // prefix blocks count_condensed = 0; // outgoing calls x ->f( UNKNOWN21 ); // suffix blocks cout << endl << "count of X in C " << count_condensed << endl; } void X::f UNKNOWN22 { // outgoing calls y ->f( UNKNOWN23 ); // assignments for carrying out count_condensed = count_condensed + 1; ; } void Y::f UNKNOWN24 { // prefix blocks y_list -> append(this); cout << endl << this << " = Y-object contained in " << b_broadcast << endl; // outgoing calls z ->f( UNKNOWN25 ); } void Z::f UNKNOWN26 { // prefix blocks cout << endl << "Z-object = " << this << endl; } QUESTION 5: ================================== 9 UNKNOWNS, 3 points each: 27 points The class dictionary: Ex = A. A : B | C *common* Q. B : D | E. C = . D = F. E = . F = . Q = . has part clusters (for construction classes only): Ex = {C,D,E}. C = {Q}. D = {Q} {F} E = {Q}. F = . Q = . What are the part clusters of the following class dictionary? A = B C D. B : X | Y *common* K L. C : U | V. D : R | S. X = C D. Y = . U = B D . V = . R = B C. S = . K = . L = . Find the UNKNOWN's in the following part clusters: A = UNKNOWN1. X = UNKNOWN2. Y = UNKNOWN3. U = UNKNOWN4. V = UNKNOWN5. R = UNKNOWN6. S = UNKNOWN7. K = UNKNOWN8. L = UNKNOWN9. HAPPY HOLIDAYS!!!