MidTermExam07 Solu

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Name _____________________________

Student Number______________________

Fall 2007
SFWR ENG 3KO4 / 3MO4
Software Development For Computer / Electrical Engineering
INSTRUCTOR: Dr. Kamran Sartipi

DAY CLASS
DURATION OF EXAMINATION: 50 Minutes
MCMASTER UNIVERSITY MIDTERM EXAMINATION October 18, 2007

THIS EXAMINATION PAPER INCLUDES 6 PAGES AND 7 QUESTIONS. YOU ARE RESPONSIBLE
FOR ENSURING THAT YOUR COPY OF THE PAPER IS COMPLETE.

BRING ANY DISCREPANCY TO THE ATTENTION OF YOUR INVIGILATOR.

Special Instructions:

Answer to each question only in the provided space for that question.
Your answer to each question should be brief.
Answer all questions.
Total mark is 100.

Midterm Exam: SE 3KO4/3MO4 Page 1 of 6 Fall 2007


Question (1): Short definitions 8 marks

Match a proper name for each definition:

1. General guideline that governs the execution of some activity; this guideline is a rigorous,
systematic, and disciplined approach.
2. Similar to above but has more restricted applicability and is more mechanical.
3. Used to promote a certain approach to solving a problem.
4. Developed to support the application of the three above.

a) Method (1)
b) Tools (4)
c) Methodology (3)
d) Technique (2)

Question (2): Finite State Machine 12 marks

Consider the Finite State Machine (FSM) below and answer the following questions:
a) Which of the following compiler components uses FSM:

Code-generator Parser Lexical scanner Symbol table

b) For the new state qeror (shown below), add the corresponding arrows such that this FSM only
recognizes two words.

Question (3): Short definitions 12 marks

Answer True or False to the following definitions:

1. Each module delivers a single functionality through its interfaces. True


2. In a modular system, the interactions among modules are high. False
3. Software views refer to organizing different types of information about the system into different
diagrams. True
4. Meaningful naming convention must be in place for the module and its exported functions. True
5. Legacy software systems are large, complex, and mission critical systems that are in use for less
than five years. False
6. Information hiding refers to encapsulating changeable design decisions of a system. True

Midterm Exam: SE 3KO4/3MO4 Page 2 of 6 Fall 2007


Question (4): Functions and sets 16 marks

In Z schema InvoiceOrder below:

orders is a partial function from OrderId to Order.


Order and stock are bags in the form {<a, 5>, <b, 9>, <c, 4>, ….<n, 12>}, where a, b, c,.. are items and
5, 9, 4, .. are their quantities.
⊕ is function overriding.
a is maplet.
U_with_bar_inside in line 3 from bottom means bag subtraction.

a) Which lines are pre-condition and which lines are post-condition?


Pre-condition: lines 3 and 4.
Post-condition: lines 5, 6 and7.

b) In a bullet form, briefly explain what does each line mean.

1) The state of InvoiceOrder will change


2) Input id? is of type OrderId.
3) All items (<item, quantity>) of the order must exist in the stock.
4) The status of the order must be pending.
5) Items in stock-after-invoicing are equal to items in stock-before-invoicing minus the
items in the order.
6) The set orders-after-invoicing is equal to the set of orders-before-invoicing.
7) The status of the order-after-invoicing will be changed to invoicing, by overriding its
previous status (i.e., pending) using a maplet.

Question (5): Z schema for elevator 20 marks

Consider the description of an elevator in Z schema that we discussed in class (shown below). The elevator
has 20 floors. The table below shows the status of the internal request signals (only signals that are ON are
shown), and external request signals. The elevator is currently in floor 10 (F10) and its direction is UP.
The elevator system uses three sets “Pri1”, “Pri2”, and “Pri3” to manage the strategy for serving
different internal and external requests. Based on the specifications for these three sets, answer the
followings:

a) Using the schema “System” show the contents of the sets “Pri1”, “Pri2”, and “Pri3 in terms of
the floor numbers in each set.

Midterm Exam: SE 3KO4/3MO4 Page 3 of 6 Fall 2007


Pri1= {F14, F16, F18, F20} Signal UP in F20 can be deleted (Top floor and UP!).
Pri2= {F19, F18, F14, F9, F8, F5, F4, F1} Signal Down in F1 can be deleted (First floor and Down!).
Pri3={F4, F6, F9}.

b) For each set in (a) show which floor will get service first.
Next Floor To Serve = F14

Floor # Int. Req Ext. Req


F20 ON UP
F19 DWN
F18 DWN /
UP
F17
F16 ON UP
F15
F14 ON DWN
F13
F12
F11
F10
F9 DWN /
UP
F8 ON
F7
F6 UP
F5 ON
F4 ON DWN /
UP
F3
F2
F1 ON DWN

Midterm Exam: SE 3KO4/3MO4 Page 4 of 6 Fall 2007


Question (6): Component diagram 14 marks

Figure below illustrates the component diagram of a “Fast Food Restaurant System” that
we discussed in class. In bullet form explain the steps for performing the following services:

1. Taking customer orders from the restaurant menu by order takers and handling order payment.
a. Order Taker (OT) gets Menu from Database (by invoking DatabaseQuery service), and
shows Menu to the customer.
b. OT sets up an order for the customer (according to customer’s choice of menu items) and
stores the “completed” but “unpaid” order in Database (again using Database interface).
c. OT receives proper cash from customer and changes the status of the new order from
“unpaid” to “paid” (by invoking Database Query interface).

2. Assembling orders from chutes and delivering the orders to the customers.
a. OT informs Assembly Coordinator (ASC) (via NewOrderCompleted) that a new
“completed” order is in Database to be assembled.
b. ASC retrieves new order from Database (as above).
c. ASC sends new order to an available assembler by invoking DisplayOrder interface.
d. Assembler fetches proper food items from Chute (via Get_items interface) and assembles
the order but does not deliver it to the customer.
e. ASC informs Assembler that the order has been “paid” (using DeliverOrder) and the
Assembler delivers the order to customer.

3. Suggest one way to enhance this component diagram.


a. Changing the components’ service names with more meaningful names.
b. Dividing Database into two databases, one for fixed system tables (such as menus, food-
recipes, etc.) and one for dynamic tables (such as orders and payments).

In your answer you should use different types of data in the “Database” component.

Midterm Exam: SE 3KO4/3MO4 Page 5 of 6 Fall 2007


Question (7): Statechart 18 marks

In figure below, an activity-chart and its corresponding statechart are shown.


Answer the following questions:
a) How do these two diagrams communicate to control a system?
a. In the Activity Chart (AC) there is a box with label (@SYSTEM) which represents a
StateChart (SC) that controls the sequence of activation of the activities. These two charts
AC and SC interact via the control signals in the AC (dashed arrows) that send trigger
events to the SC. As a result of these events, the satechart transits to another state and in
that state activates an activity in AC.

b) What is the use of “Data Dictionary” in this communication?


a. All entities in the whole system are defined (and bound together) within the Data
Dictionary forms. For example an event that triggers a transition in a statechart is usually
bound to a push-button in the user interface, or a condition is bound to an Off/On switch.

c) Assume that these two charts are used to design a process of generating documents and printing
them. In a bullet form, explain how this process can be performed by this design.
a. In AC the user starts the operations by initiating a Power-On signal which causes the SC
to transit from Off state to On state, and then will wait in the WAIT state.
b. User in AC sends proper system data to INIT activity which sets up the system and issues
the signal “Execute” to SC and consequently the concurrent (and) state EXECUTING is
activated and both states A and Y become active. State A enables activity A which in turn
receives the document file (e.g., a latex file) from the user (as external activity) and
operates on it.
c. The resulting file (e.g., a postscript file) will be stored in the data store in AC.
d. In the next step both states B and Z from SC will be active. Entering in state B enables
activity B in AC which receives the latex file from data store and generates a postscript
file and sends it to the printer (shown as OUT external activity).
e. Also the states Y and Z will be alternatively activated which can be interpreted as: when
Z is active it enables activity Z in AC that monitors the status of the files in the Datastore.
If some anomaly in the intermediate files in datastore occurs, then activity Z recognizes
that and will generate event “Reset” which triggers the corresponding event Reset and all
activities in the system stop and the system enters the WAIT state again, waiting for the
user to initialize the system through activity INIT in AC.

THE END: GOOD LUCK

Midterm Exam: SE 3KO4/3MO4 Page 6 of 6 Fall 2007

You might also like