-------------------------------------------------------------------------- Software Design and Development Fall 1993 COM 1205 --------------------------------------------------------------------------- Midterm 117 points total Q1: 12 Q2: 15 Q3: 56 Q4: 34 --------------------------------------------------------------------------- Open book and open notes. 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. All the questions use the following class dictionary, called PD: //////////////////////////////////////////////////////////////////////// // propagation directive expressions //////////////////////////////////////////////////////////////////////// Example =

List(Propagation_directive_exp). Propagation_directive_exp = "*from*" Vertex_selector [ Path_constraint_exp ] List(Segment). Segment = Targets [ Path_constraint_exp ]. Targets = To_or_via Vertex_selector . To_or_via : To | Via | Tostop. Via = "*via*". To = "*to*". Tostop = "*to-stop*". Path_constraint_exp : Require_through | Require_bypassing. Require_through = Through_path_constraint [ Bypassing_path_constraint ]. Require_bypassing = Bypassing_path_constraint [ Through_path_constraint ]. Through_path_constraint = "*through*" Commalist(Meta_edge). Bypassing_path_constraint = "*bypassing*" Commalist(Meta_edge). Meta_edges = Commalist(Meta_edge). Meta_edge : Meta_construction_edge | Meta_alternation_edge | Meta_repetition_edge | Meta_inheritance_edge. Meta_construction_edge = "->" Vertex_selector "," Label_selector "," Vertex_selector . Meta_alternation_edge = "=>" Vertex_selector "," Vertex_selector . Meta_inheritance_edge = ":>" Vertex_selector "," Vertex_selector . Meta_repetition_edge = "~>" Vertex_selector "," Vertex_selector . Vertex_selector : Any_term | Fixed_term | Vertex_set. Any_term = "*". Fixed_term = Vertex. Vertex_set : Vertex_set_sim | Vertex_set_comp | Class_set_name | Late_selected_terms. Class_set_name = "*class-set*" DemIdent . Vertex_set_sim = "{" Commalist(Fixed_term) "}" . Vertex_set_comp = Vertex_set_op Vertex_set Vertex_set ")". Vertex_set_op : Union | Intersect. Union = "(*union*". Intersect = "(*intersect*". Late_selected_terms = "(*class-set*" Propagation_directive_exp ")". Label_selector : Any_edge_label | Relation_meta_var | Label_set. Label_set = "{" Commalist(Relation_meta_var) "}". Any_edge_label = "*". Relation_meta_var = DemIdent. Vertex = < vertex_name > DemIdent. ///////////////////////////////////////////////////////////////////////////// // parameterized classes ///////////////////////////////////////////////////////////////////////////// List(S) ~ {S}. Commalist(S) ~ S {"," S}. In pictorial form: Example(

List -|List (Propagation_directive_exp( |-|Propagation_directive_exp Vertex_selector( | |-|Vertex_selector |Any_term() | | | |Fixed_term( | | |-|Fixed_term Vertex( | | | | DemIdent)) | | | |-|DemIdent |Vertex_set( | | | | |-|Vertex_set |Vertex_set_sim( | | | | | | Commalist | | | | | |-|Commalist (Fixed_term)) | | |-| | | | |Vertex_set_comp( | | | | | | Vertex_set_op( | | | | | | |Union() | | | | | | |Intersect()) | | | | | | Vertex_set | | | |-| | Vertex_set) | | | |-| | |Class_set_name( | | | | | DemIdent) | | | -| | |Late_selected_terms( | | | | | Propagation_directive_exp))) |-| | | | [Path_constraint_exp]( | | | |-|Path_constraint_exp |Require_through( | | | | | Through_path_constraint( | | | | |-|Through_path_constraint Commalist | | | -| | | (Meta_edge( | | | | | |-|Meta_edge |Meta_construction_edge( | | | | | | | Vertex_selector | -| | | | | | Label_selector( | | | | | | | |Any_edge_label() | | | | | | | |Relation_meta_var( | | | | | | |-|Relation_meta_var DemIdent) | | -| | | | | | |Label_set( | | | | | | | Commalist | | -| | | | | (Relation_meta_var))) | | | | | |-| Vertex_selector) | -| | | | | |Meta_alternation_edge( | | | | | | Vertex_selector | -| | | | | Vertex_selector) | -| | | | | |Meta_repetition_edge( | | | | | | Vertex_selector | -| | | | | Vertex_selector) | -| | | | | |Meta_inheritance_edge( | | | | | | Vertex_selector | -| | | | | Vertex_selector)))) | -| | | | | [Bypassing_path_constraint]( | | | | | |-|Bypassing_path_constraint Commalist | | -| | | | | (Meta_edge))) | | | | |-| | |Require_bypassing( | | | | | | | Bypassing_path_constraint | | | | | |-| [Through_path_constraint])) | | | |-| | List -| | | | | (Segment( | | | | | Targets( | | | | | To_or_via( | | | | | |To() | | | | | |Via() | | | | | |Tostop()) | | | | | Vertex_selector) | -| | | | [Path_constraint_exp]))))) | |-| | Meta_edges( | | | Commalist | -| | (Meta_edge)) | | -| List -| | (S)( | {S}) | Commalist -| (S)( S {S}) Question 1: 12 UNKNOWNs. 1 point per UNKNOWN. ------------------------------------------------------------------- Consider the following class definition for class Propagation_directive_exp for class dictionary PD. Find the UNKNOWNs. class Propagation_directive_exp : public Construction { private: UNKNOWN1* UNKNOWN2; UNKNOWN3* UNKNOWN4; UNKNOWN5* UNKNOWN6; static const char* type; public: Propagation_directive_exp( UNKNOWN7* = NULL, UNKNOWN8* = NULL, UNKNOWN9 = NULL ); ~Propagation_directive_exp(); Vertex_selector* get_source_port() const { return( UNKNOWN10 } void set_source_port( Vertex_selector* new_source_port ) { UNKNOWN11 new_source_port; } Vertex_selector* rset_source_port( Vertex_selector* ); Path_constraint_exp* get_constraint() const { return( constraint ); } void set_constraint( Path_constraint_exp* new_constraint ) { constraint = new_constraint; } Path_constraint_exp* rset_constraint( Path_constraint_exp* ); Segment_List* get_via() const { return( via ); } void UNKNOWN12 Segment_List* new_via ) { via = new_via; } Segment_List* rset_via( Segment_List* ); const char* get_type() const { return( type ); } static const char* get_formal_type() { return type; } void set_data_member( int, Universal* ); Universal* get_data_member( int ) const; int number_of_parts() const; int number_of_imm_parts() const; void DEM_abstract() { } void pp( ostream& = cout ) const; #include "Propagation_directive_exp.h" }; Question 2: 5 UNKNOWNS, 3 points each. ------------------------------------------------------------------ Consider the propagation graph below and find the UNKNOWNs in the propagation directive. PD is the class dictionary. Traversal directive: *traverse* *from* UNKNOWN1 *bypassing* -> *,UNKNOWN2,* , -> *,UNKNOWN3,* *UNKNOWN4* UNKNOWN5 Propagation graph for traversal: Example = < p > Propagation_directive_exp_List . Propagation_directive_exp = < via > Segment_List . Segment = . Propagation_directive_exp_List ~ { Propagation_directive_exp } . Segment_List ~ { Segment } . ///////////////////////////////////////////////////////////////// // There are 40 classes in total // There are 5 classes in the propagation schema // There are 35 classes not in the propagation graph ///////////////////////////////////////////////////////////// Question 3: 28 UNKNOWNs, 2 points each. ------------------------------------------------------------- Consider the following propagation pattern, object, corresponding sentence and output from running the propagation pattern. Find the UNKNOWNs in the propagation pattern and in the object. Use PD. *operation* void f1() *traverse* *from* UNKNOWN1 *to* UNKNOWN2 *wrapper* UNKNOWN3 *prefix* (@ UNKNOWN4 -> UNKNOWN5(); @) *operation* void f222() *wrapper* UNKNOWN6 *prefix* (@ this -> UNKNOWN7(UNKNOWN8); @) *operation* void f55(UNKNOWN9* x) *traverse* *from* UNKNOWN10 *to* UNKNOWN11 *wrapper* UNKNOWN12 *prefix* (@ this -> f3333333(); cout << endl << this << endl << x < f222(); @) : Example ( < p > : Propagation_directive_exp_List { : Propagation_directive_exp ( < UNKNOWN16 > : UNKNOWN17 ( < vertex > : Vertex ( < vertex_name > : UNKNOWN18 "UNKNOWN19" ) ) < via > : UNKNOWN20 { : Segment ( < targets > : Targets ( < to_or_via > : UNKNOWN21 ( ) < targets > : UNKNOWN22 ( < name > : UNKNOWN23 "UNKNOWN24" ) ) < constraint > : UNKNOWN25 ( < bypassing > : Bypassing_path_constraint ( < bypassing > : Meta_edge_Commalist { : Meta_construction_edge ( < from > : Late_selected_terms ( < pde > : Propagation_directive_exp ( < source_port > : Fixed_term ( < vertex > : Vertex ( < vertex_name > : DemIdent "A" ) ) < via > : Segment_List { : Segment ( < targets > : Targets ( < to_or_via > : To ( ) < targets > : Late_selected_terms ( < pde > : Propagation_directive_exp ( < source_port > : Fixed_term ( < vertex > : Vertex ( < vertex_name > : DemIdent "B" ) ) < via > : Segment_List { } ) ) ) ) } ) ) < edge_label > : Relation_meta_var ( < name > : DemIdent "r" ) < to > : Fixed_term ( < vertex > : Vertex ( < vertex_name > : DemIdent "R" ) ) ) } ) ) ) , : Segment ( < UNKNOWN26 > : UNKNOWN27 ( < to_or_via > : To ( ) < targets > : Fixed_term ( < vertex > : Vertex ( < vertex_name > : DemIdent "UNKNOWN28" ) ) ) ) } ) } ) Object represented as sentence: *from* A *via* *class-set* Q *bypassing* -> (*class-set* *from* A *to* (*class-set* *from* B)),r,R *to* Z Trace of object-oriented program: IN Example::f1 IN Propagation_directive_exp_List::f1 IN Propagation_directive_exp::f1 IN Fixed_term::f1 OUT Fixed_term::f1 IN Segment_List::f1 IN Segment::f1 IN Targets::f222 IN Targets::f55 IN Class_set_name::f55 OUT Class_set_name::f55 OUT Targets::f55 OUT Targets::f222 IN Targets::f1 IN Class_set_name::f1 OUT Class_set_name::f1 OUT Targets::f1 IN Require_bypassing::f1 IN Bypassing_path_constraint::f1 IN Meta_edge_Commalist::f1 IN Meta_construction_edge::f1 IN Late_selected_terms::f1 IN Propagation_directive_exp::f1 IN Fixed_term::f1 OUT Fixed_term::f1 IN Segment_List::f1 IN Segment::f1 IN Targets::f222 IN Targets::f55 IN Late_selected_terms::f55 IN Late_selected_terms::f3333333 IN Propagation_directive_exp::f3333333 IN Fixed_term::f3333333 OUT Fixed_term::f3333333 IN Segment_List::f3333333 OUT Segment_List::f3333333 OUT Propagation_directive_exp::f3333333 OUT Late_selected_terms::f3333333 (*class-set* *from* B ) *to* IN Propagation_directive_exp::f55 IN Fixed_term::f55 OUT Fixed_term::f55 IN Segment_List::f55 OUT Segment_List::f55 OUT Propagation_directive_exp::f55 OUT Late_selected_terms::f55 OUT Targets::f55 OUT Targets::f222 IN Targets::f1 IN Late_selected_terms::f1 IN Propagation_directive_exp::f1 IN Fixed_term::f1 OUT Fixed_term::f1 IN Segment_List::f1 OUT Segment_List::f1 OUT Propagation_directive_exp::f1 OUT Late_selected_terms::f1 OUT Targets::f1 OUT Segment::f1 OUT Segment_List::f1 OUT Propagation_directive_exp::f1 OUT Late_selected_terms::f1 IN Fixed_term::f1 OUT Fixed_term::f1 OUT Meta_construction_edge::f1 OUT Meta_edge_Commalist::f1 OUT Bypassing_path_constraint::f1 OUT Require_bypassing::f1 OUT Segment::f1 IN Segment::f1 IN Targets::f222 IN Targets::f55 IN Fixed_term::f55 OUT Fixed_term::f55 OUT Targets::f55 OUT Targets::f222 IN Targets::f1 IN Fixed_term::f1 OUT Fixed_term::f1 OUT Targets::f1 OUT Segment::f1 OUT Segment_List::f1 OUT Propagation_directive_exp::f1 OUT Propagation_directive_exp_List::f1 OUT Example::f1 Question4: 17 UNKNOWNs, 2 points each. ------------------------------------------------------------- Consider the following propagation pattern and the corresponding C++ member functions with respect to class dictionary PP. Find the UNKNOWNs in the C++ code. Use PD. Propagation pattern: *operation* void for_each() *traverse* *from* Example *to-stop* Propagation_directive_exp *wrapper* Propagation_directive_exp *prefix* (@ cout << endl << this << endl << "size" << endl << this -> size() << endl; @) *operation* int size() *init* (@ 0 @) *traverse* *from* Propagation_directive_exp *to* Propagation_directive_exp *wrapper* Propagation_directive_exp *prefix* (@ return_val += 1; @) C++ member functions: void Example::for_each( ) { UNKNOWN1 ->for_each( ); } void Propagation_directive_exp::for_each( ) { cout << endl << this << endl << "size" << endl << this -> size() << endl; } void Propagation_directive_exp_List::for_each( ) { Propagation_directive_exp_list_iterator next_Propagation_directive_exp(*this); Propagation_directive_exp* each_Propagation_directive_exp; UNKNOWN2 ( each_Propagation_directive_exp = next_Propagation_directive_exp() ) { each_Propagation_directive_exp->UNKNOWN3( ); } } int Propagation_directive_exp::size( ) { int UNKNOWN4 = UNKNOWN5 ; this->size_( UNKNOWN6 ); return UNKNOWN7; } void Propagation_directive_exp::size_( int& return_val ) { UNKNOWN8 += 1; source_port ->size_( UNKNOWN9 ); if ( constraint != UNKNOWN10 ) { UNKNOWN11 ->size_( UNKNOWN12 ); } via ->size_( UNKNOWN13 ); } void Segment::size_( int& return_val ) { targets ->size_( return_val ); if ( UNKNOWN14 != NULL ) { UNKNOWN15 ->size_( return_val ); } } void UNKNOWN16::size_( int& return_val ) { targets ->size_( return_val ); } void Path_constraint_exp::size_( int& return_val ) { UNKNOWN17 } // rest deleted