13
1 Name _____________________________ Student Number______________________ Fall 2006 SFWR ENG 3KO4 / 3MO4 Software Development For Computer / Electrical Engineering INSTRUCTOR: Dr. Kamran Sartipi DAY CLASS DURATION OF EXAMINATION: MCMASTER UNIVERSITY FINAL EXAMINATION December 12, 2006 THIS EXAMINATION PAPER INCLUDES 15 PAGES AND 10 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: Try to answer to each question only in the provided space for that question. Your answer to each question should be brief. Answer all questions. McMaster standard calculator is allowed Total mark is 100. Continue on Page 2

Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

1

Name _____________________________

Student Number______________________

Fall 2006SFWR ENG 3KO4 / 3MO4

Software Development For Computer / Electrical EngineeringINSTRUCTOR: Dr. Kamran Sartipi

DAY CLASSDURATION OF EXAMINATION:MCMASTER UNIVERSITY FINAL EXAMINATION December 12, 2006

THIS EXAMINATION PAPER INCLUDES 15 PAGES AND 10 QUESTIONS. YOUARE RESPONSIBLE FOR ENSURING THAT YOUR COPY OF THE PAPER ISCOMPLETE. BRING ANY DISCREPANCY TO THE ATTENTION OF YOURINVIGILATOR.

Special Instructions:

Try to answer to each question only in the provided space for that question.Your answer to each question should be brief.Answer all questions.McMaster standard calculator is allowedTotal mark is 100.

Continue on Page 2

Page 2: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

2

Page 2

Question 1. [10 marks]

Below is the pre-/post-condition specification of a program that inserts the customers’invoices into a file.Each invoice record is in the form of a tuple: <customer, date, amount>.

1. ∀x ∈ Invoices, f ∈ Invoice_Files2. {sorted_by_date(f) ∧ not ∃j, k (j ≠ k ∧ f(j) =f(k)}3.4. insert(x, f)5.6. {sorted_by_date(f) ∧7. ∀k (old_f(k) = z → ∃j (f(j) = z)) ∧8. ∀k (f(k) = z ∧ z ≠ x) → ∃j (old_f(j) = z) ∧9. ∃j (f(j). date = x. date ∧ f(j) ≠ x) → j < position(x, f)}

Answer the following questions:

1. What are the purposes of pre-condition and post-condition statements in softwarespecification?

Pre-condition statements describe the conditions on the input parameters that musthold (as a part of contract) such that the procedure can generate its specifiedoutputs (by performing its intended operations).

Post-conditions refers to the properties that the procedure guarantees to be held onthe outcome of the procedure.

2. Describe the pre-conditions in lines 1 and 2.

For every invoice x and for every invoice-file f, file f must be sorted by date andthe invoices in each invoice-file f are unique

Describe the post-condition using the line numbers.

Continue on Page 3

Page 3: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

3

Page 3Lines 6 and 7: file f is sorted, and all invoices in file f before insertion also exits in file fafter insertion of x. This means the insertion operation does not delete any invoices fromthe old invoice file.

Line 8: every invoice in the invoice-file after insertion of an invoice already exists in theold-invoice-file lists. In other words, the insertion operation does not add new invoice inthe invoices.

Question 2. [12 marks]

We intend to design a Fire Alarm System for a building with two apartment units. Thesoftware specification for the alarm system is as follows:

• The alarm system has an ON/OFF switch to activate or deactivate the wholesystem.

• Each apartment unit has a smoke sensor.• When the smoke is sensed in one apartment unit, the alarm in that unit starts

ringing.• If the smoke is gone in less than 5 minutes then the alarm in that unit will stop

ringing.• If the alarm remains activate for more than 5 minutes, then the alarm system in

both units become activate; and a message is sent to the fire station.

Design a component diagram and a statechart for this Fire Alarm System and use thetime-based transitions with label: tm( entered(state A), delayedTime), that triggers atransition after “delayedTime” that the system enters state A.

Page 4: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

4

Page 5: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

5

Question 3. [14 marks]

Using the simplified ABM component diagram shown below, specify the sequence of alloperations, including: “customer interactions with the ABM user-interface” and “serviceinvocations by the components” that are required to perform the following scenarios:

1. Authorize the card, transfer $200 from chequing account to saving account and thenask the balance in chequing account.

User inserts the card in the card-holder and types-in the PIN number. User-interface asksthe Bank System Interface to validate the PIN and card number. After validation, userselects transfer money, and indicates the source and destination accounts and the amount$200. UI invokes Transfer service from Transactions and provides the data obtained fromUser interaction. Transactions will use “Get account balance” from source anddestination accounts, updates both accounts and writes back the new account balancesusing “Set account balance”. Finally, the UI uses the “Get all accounts for ID” to obtainall user’s accounts and only displays the checking and saving accounts to the user.

2. An operator re-stocks the ABM machine with the amount of $20,000.(since the “Low Stock Alarm” in the Bank System is on)

The operator uses ON/OFF key to enter the operator-mode. The “Staff Operation”component overrides the authorization mechanism of the UI. Operator re-stocks$20,000 into ABM machine and uses the keypad to enter the amount. UI uses “Re-stock” to inform Transactions component. Transaction uses Set account balance toinform Bank System the amount of re-stock money.

Page 6: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

6

3. Random test case generation: given the minimum set of service invocations, asfollowing: PINvalidityInqury > GetAllAccountsForID

define a general sequence of service invocations using the notation “ [ ] n “ (i.e.,repetition 0 to n) and “ | “ (i.e., logical OR) such that the sequence covers all thetransactions of the ABM. Then give two random test cases from the general testsequence.

PINvalidityInqury > [Deposit | Withdraw | Transfer | Balance inquiry ]n >GetAllAccountsForID

PINvalidityInqury > Deposit > Withdraw > Balance inquiry > GetAllAccountsForID

PINvalidityInqury > Transfer > Balance inquiry > GetAllAccountsForID

Question 4. [7 marks]

In the following, the steps for developing a compiler are shown.Put a proper activity (from the list below) into each set of parentheses in the text.

(1) Symbol table; (2) Machine language code; (3) Source code; (4) Token; (5) Assembly code; (6) Parameter; (7) Module; (8) Syntax tree; (9) Grammar;

(a) Scanner uses ((3) Source code ) to generate ((4) Token ) and ((1) Symbol table ).

(b) Parser uses ((4) Token ) and ((9) Grammar ) to generate ((8) Syntax tree ).

(c) Code generator attaches pieces of assembly code to ((8) Syntax tree ) and thentraverses ((8) Syntax tree ) to generate ((5) Assembly code ).

(d) Assembler program uses ((5) Assembly code ) and generates ((2) Machinelanguage code ).

(e) Linker puts together ((2) Machine language code ) files to generate an executablefile to be run on the computer.

Question 5. [8 marks]For each of the following UML diagrams, briefly explain:

1. Usage: how is that diagram used in designing a software system?

2. Concepts: select the major concepts used in that diagram from the list below:

class, use case, component, node, state, interaction, collaboration, association,

Page 7: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

7

actor, interface, dependency, event, activity, object, interaction, generalization,extend, include, dependency, transition, fork, join, role, generalization, action,message, activation.

A sample answer to the usage part of the “sequence diagram” has been provided below.

a) Sequence diagram:Usage: a sequence diagram specifies the time sequences of the interactions amongdifferent system components.

Concepts:

b) Class diagram:Usage:

Concepts: Class; Association; Generalization;

C) Use case diagram:Usage: models the functionality of the system with regard to the outside users, calledactors and is expressed as a transaction among actors and the system. A use case is acoherent unit of functionality expressed as a transaction among actors and the system.Use case diagram shows which actors participate in which use case.

Concepts: Use case; Role; Association; Include; Extend

D) Component diagram:Usage: represents the software system as a group of physical components (such as files,directories) from which the system is constructed. The components interact using theinvocation of services that are provided by the components through dependency links.

Concepts: Component; Interface; Dependency;

E) Statechart diagram:Usage: statecharts represent the control aspects of the software system; throughtransitions among different states of the system. The system reacts to internal or externalevents by changing its states, performing actions, and generating new evens.

Concepts: State: Event; Action

Page 8: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

8

Question 6. [7 marks]In the context of Capability Maturity Model (CMM) answer True or False to thefollowing questions:

(a) CMM tool can be used by the immature organizations to develop high-quality systems specifically for the object oriented systems. False

(b) Organizations that acquire software can use CMM to assess the quality oftheir contractors’ products. True

(c) At level 1 (Initial), the process is ad-hoc and chaotic and the individualsuse organization-wide standards in their day-by-day practices. False

(d) At level 2 (Repeatable), the input-output of the processes and theresources are completely known by the managers, hence the processes arerepeatable. But it is highly relied on the managers. True

(e) At level 3 (Defined), the processes are documented and standard. Themajor responsibility of the manager is to define data formats for thedevelopers. False

(f) At level 4 (Managed) there is an organization-wide standard and data fromthe process is collected to improve and enhance the standards. True

(g) There is no level 5. False

Question 7. [10 marks]Figure below illustrates the class diagram of a ticket selling box office in a theatre, wherethe tickets can be reserved either individually or in a series of tickets (subscriptionseries). Specify as many as different relations that exist in this box office.

Page 9: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

9

- A customer can purchase zero or more reservations- Reservations can be either individual or subscription series (i.e., a set of

reservations).- Each subscription series is between 3 and 6 tickets.- Each individual reservation is one ticket.- Each performance many tickets that correspond to the seats in the performance- Each show is performed once or more.

Question 8. [14 marks]

1) Draw a simple class diagram consisting of an abstract-class A (super-class) withtwo methods M1() and M2(). Class A has two concrete sub-classes B and C.Using this class diagram, define the concepts “polymorphism” and “dynamicbinding” in object oriented programs.

Page 10: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

10

- Polymorphism: a variable referring to type A can refer to an object of type B(since B is a subclass of A).

- Dynamic binding: the method invoked through a reference depends on the typeof the object associated with the reference at runtime.

2) Answer False or True to each of the following statements:

a. Only the super-classes of an abstract-class can generate objects. False

b. A concrete class can generate objects but not an abstract class. True

c. Abstract classes only provide the general interfaces of all their sub-classes.True

d. The sub-classes of an Abstract class can have different implementationsfor the inherited methods. True

3) Figure below illustrates an Abstract Factory Design Pattern (AFDP) that is used togenerate families of similar applications. Using the below class diagram for AFDPand the sample code answer the following questions:

a. Explain what happens in each line 4, 7, 10, and 11, and what would be thetype of the object “wallCabinet_1”. (note: method “kitchen.add()”accumulates different kitchen-items for the kitchen).Line 4: a reference variable myStyle (of type KitchenStyle) is generatedthat references an object of the class ModernStyle (POLYMORPHISM)Line 7: a reference variable “wallCabinet_1” is defined that references toan object of class “ModernWallCabinet”Line 10: a variable kitchen is defined that references to the object of classKitchen.Line 11: a modern wall cabinet is added to the kitchen.

Page 11: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

11

b. Briefly explain how dynamic binding is used in this design pattern.

Dynamic binding is realized in line 7, as following: reference variable“wallCabinet_1” which is of type abstract class “WallCabinet” will referenceto an object of the concrete class “ModernWallCabinet” at run time.

1 // Determine style by instantiating my Style of type KitchenStyle2 // to be either “ModernKStyle” or “AnticKStyle”34 myStyle KitchenStyle = new ModernStyle ();56 // Create the wall cabinets7 WallCabinet wallCabinet_1 = myStyle.getWallCabinet ();8 …..9 //Create the kitchen object10 Kitchen kitchen = new Kitchen ();11 kitchen.add ( wallCabinet_1, ….);

Page 12: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

12

Question 9. [13 marks]In the context of Web Services Technology answer the following questions:

1. What is the full name of each of the following technologies? For each technology,briefly describe its usage.

SOAP: Simple Object Access Protocol:an XML-based protocol for both messaging and remote procedure call (RPC)communication that is built on top of common internet protocols: HTTP, SMTP.

WSDL: Web Services Description Language:an XML format to describe Web Services as a collection of communication end-points that can exchange certain messages. Using WSDL, we describe the abstractand concrete interfaces for a web service to be published on the UDDI. During thedevelopment process, the developers use WSDL documents as the input to a Proxygenerator tool that produces client code according to the service requirements.

UDDI: Universal Description, Discovery, and Integration:UDDI provides a unified and systematic way to find Service Providers throught acentralized registry of services that is roughly equivalent to an automatic on-linephone directory.

2.

Using figure below, briefly define the steps for development of the Service Providerand also put the labels of the five blank boxes in the figure.

3. Figure below presents the structure of a SOAP message. Answer the followingquestions:

Page 13: Name Student Number SFWR ENG 3KO4 / 3MO4 DURATION OF ... · Your answer to each question should be brief. Answer all questions. ... We intend to design a Fire Alarm System for a building

13

a. Briefly explain what does part A do?

Part A is the header of the SOAP and defines the types of the xmlvariables such as SOAP, xsd, and xsi that are used in part B (Body ofSOAP).

b. Briefly explain what does part B do?Part B defines the structure of the message using the types obtained in theheader in part A.

Question 10. [5 marks]In the context of Unified Software Development Process, answer True or False to thefollowing descriptions:

(a) Inception: roughly corresponds to the feasibility study of the Waterfallmodel. True

(b) Elaboration: the use cases that correspond to the current software releaseare specified in detail, and software architecture is developed andspecified that would be the basis for the development. True

(c) Construction: the agreed on software architecture is re-assessed anddiscarded in order to build a new version of the software. False

(d) Transition: the system is developed and tested based on inception phase.False

GOOD LUCKTHE END