CPSC 410? Advanced Software Engineering Mid-term Examination (Term I ) SOLUTION Instructor: Gail Murphy

Similar documents
CPSC 410 Advanced Software Engineering Mid-term Examination (Term I ): Solution Instructor: Gail Murphy

EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

S.O.L.I.D: Software Engineering Principles

Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

CPSC 121 Midterm 1 Friday October 14th, Signature: Section (circle one): 11:00 15:30 17:00

This examination has 11 pages. Check that you have a complete paper.

Lecture: Modular Design

Question Marks 1 /11 2 /4 3 /13 4 /5 5 /11 6 /14 7 /32 8 /6 9 /11 10 /10 Total /117

Question Marks 1 /20 2 /16 3 /7 4 /10 5 /16 6 /7 7 /24 Total /100

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

UNIVERSITY REGULATIONS

CPSC 311, 2010W1 Midterm Exam #2

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 110: MIDTERM 1 Part B May 26, Important notes about this examination

EXAMINATION INSTRUCTIONS

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)

CPSC 121 Sample Final Examination December 2013

CPSC 320 Midterm 2. July 13, 2007

UNIVERSITY REGULATIONS

Software Architecture

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

Chapter 6: Inheritance

Question Marks 1 /16 2 /13 3 /12 4 /15 5 /8 6 /15 7 /8 8 /5 9 /8 Total /100

CPSC 411, 2015W Term 2 Midterm Exam Date: February 25, 2016; Instructor: Ron Garcia

CPSC 121 Midterm 1 Friday February 5th, Signature: Section (circle one): Morning Afternoon

Liskov Substitution Principle

Computer Science 304

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

Object Oriented Software Design - I

Software Architecture

Full Name: CS Account:

The University of Oregon May 16, 2015 Oregon Invitational Mathematics Tournament:

Software Engineering CSC40232: SOFTWARE ENGINEERING. Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 121: MIDTERM 2 Group March 12, 2014

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

READ AND OBSERVE THE FOLLOWING RULES:

The University of British Columbia Final Examination - December 02, 2014 Mathematics 308. Closed book examination. No calculators.

6/20/2018 CS5386 SOFTWARE DESIGN & ARCHITECTURE LECTURE 5: ARCHITECTURAL VIEWS C&C STYLES. Outline for Today. Architecture views C&C Views

Chapter 6 Introduction to Defining Classes

EXAMINATION INSTRUCTIONS

CS 411 Midterm Feb 2008

Component-Level Design

The University of Oregon May 16, 2015 Oregon Invitational Mathematics Tournament:

New Programming Paradigms

Practice Problems. Review, with SOME solutions

Inheritance and Interfaces

Inheritance and object compatibility

Architectural Styles. Reid Holmes

What are the characteristics of Object Oriented programming language?

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

CSc 328, Spring 2004 Final Examination May 12, 2004

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

Unit Wise Questions. Unit-1 Concepts

Test Code Patterns. How to design your test code

The University of British Columbia Computer Science 304 Practice Final Examination

Testing and Inheritance. Test Code Patterns. Inheritance-related bugs. Inheritance. Testing of Inheritance. Inheritance-related bugs

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Chapter 5 Object-Oriented Programming

CSE 131 Introduction to Computer Science Fall Exam II

Object Oriented Programming

11/2/09. Code Critique. What goal are we designing to? What is the typical fix for code smells? Refactoring Liskov Substitution Principle

Basic Properties of Styles

Design Principles: Part 2

MechEng SE3 Lecture 7 Domain Modelling

Outline. Design Principles: Part 2. e.g. Rectangles and Squares. The Liskov Substitution Principle (LSP) ENGI 5895: Software Design.

Sample Examination Paper Programming and Software Development

CSE wi Final Exam 3/12/18. Name UW ID#

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Final Examination 8:30 AM, Wednesday, April 18, 2012

Object-Oriented Design

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn how to describe objects and classes and how to define classes and create objects

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Design Principles: Part 2

Software Architecture

Principles of OO Design

CSE 70 Final Exam Fall 2009

1. (a) How does Object Oriented Programming facilitate the creation of reliable, reusable, extensible and adaptable code? [4]

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

Inheritance and Polymorphism

Architectural Design. Architectural Design. Software Architecture. Architectural Models

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

Reviewing OO Concepts

Inheritance. Quick Review of Last Lecture. November 12, Passing Arguments. Passing Arguments. Variable Assignment Revisited

CAS 703 Software Design

Engr. M. Fahad Khan Lecturer Software Engineering Department University Of Engineering & Technology Taxila

MATH 253/101,102,103,105 Page 1 of 12 Student-No.:

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 261: MIDTERM 1 February 14, 2017

Software Architecture

Object Oriented Programming and Design in Java. Session 10 Instructor: Bert Huang

ESC101 : Fundamental of Computing

Computer Science 1 Bh

Applying UML Modeling and MDA to Real-Time Software Development

CPSC 126 SAMPLE FINAL EXAMINATION ANSWERS April, 2003

Exam in TDDB84: Design Patterns,

EXAMINATION INSTRUCTIONS

Department of Computer Science Undergraduate Events

SoberIT Software Business and Engineering Institute. SoberIT Software Business and Engineering Institute. Contents

Transcription:

CPSC 410? Advanced Software Engineering Mid-term Examination (Term I 2001-2002) SOLUTION Instructor: Gail Murphy Do NOT start until you are informed you can start! This examination has 7 questions. The question and answer space is from page 2 to page 11. Page 12 provides a short UML reference. Check that you have a complete paper when you are told that you can start the examination. You have 80 minutes to complete this exam. Before you start, you must write your student id number on the top of every sheet of this exam. We will not mark your exam without this information. You must also sign your name in the space provided below. Write legibly and in ink (not pencil). We also have to be able to read it to mark it. This exam is closed book and closed neighbour. Notes, book, or other materials are not allowed. Candidates guilty of any of the following, or similar, dishonest practices shall be immediately dismissed from the examination and shall be liable to disciplinary action:?? Making use of any books, papers or memoranda, calculators or computer, audio or visual cassette players, or other memory aid devices, other than those authorized by the examiners.?? Speaking or communicating with other candidates.?? Purposely exposing written papers to the view of other candidates. The plea of accident or forgetfulness shall not be received. If you have a question during the exam, raise your hand and one of the invigilators will come and answer your question. The exam is out of 100 marks. The value of each question is indicated. Use your time wisely. If you do not know the answer to a question, move on to the next question and come back to the question at the end. The exam is double-sided. There are questions on both sides of the page. Good luck! Print Name: Signature: October 18, 2001 1 of 13

1. (Total: 20 points. 2 points each.) True or false with justification. For each statement below, circle T if the statement is true or F if the statement is false. In the space provided for each statement, write at most two sentences explaining your choice. (a) A system is designed well if its components are highly coupled. A good design will have components that are highly cohesive and minimally coupled. (b) In a system whose software architecture conforms to a 2-tier client/server style, the only responsibility of the client is to provide the graphical user interface to the system. In such a system, the client is fat, it likely contains business logic as well as GUI functionality (c) The Software Architecture Analysis Method uses use-cases as a basis for evaluating a software architecture. SAAM uses scenarios that differ from use-cases by encompassing more interactions with the system, such as the interaction of developers performing maintenance tasks. (d) The repository and blackboard architectural styles share many similarities. Yes, they are both sub-styles of the data centered architecture. (e) The order in which components in a batch sequential architectural style shall execute must be determined at compile-time. No, it can be determined at run-time. October 18, 2001 2 of 13

(f) A client accesses a COM object through at most one interface. No, a client can use multiple interfaces to access a COM object. (g) When architecting a system using an object-oriented style, it is beneficial to create a view of the architecture showing the classes and the messages between objects of those classes. Such a view can provide a useful dynamic view of how the system will execute. (h) A system whose architecture conforms to a 3-tier client/server style can scale to handle a large number of users. A number of application servers can be introduced to perform load sharing. (i) The Observer Design Pattern is an example of an explicit invocation architectural style. Observer supports an implicit invocation architectural style. (j) When designing using an object-oriented approach, it is good design practice to ensure the class is closed for modification Yes, classes should be closed for modification but open for extension. October 18, 2001 3 of 13

2. (Total: 10 points. 2 points each.) Short Answer. Define the following terms in five sentences or less each. a. Stakeholder. A stakeholder is a person or an organization that has an interest in the construction of a software system. b. Package-oriented Programming.. In package-oriented programming, an application is created by gluing together existing (off-theshelf) applications and components. c. Information Hiding. When an information hiding approach is used during design and implementation, modules are selected to hide design decision(s). Information hiding is achieved through the appropriate choice of interfaces to the module. d. Architectural Style. A description of a common way to architect a system, providing a framework on which to base design. A style typically consists of components, connectors, semantic constraints on the components and connectors, and a description of the typical system topology. e. Product Line. A collection of systems that share a managed set of features constructed from a common set of software assets. October 18, 2001 4 of 13

3. (Total: 10 points) Architectural Views. a) (8 marks) Briefly describe the 4 views that constitute the 4+1 approach to describing a software architecture. 1) Logical View this view supports the functional requirements: how will the system perform the functions the user is interested in. 2) Development View this view supports the developers: It shows the module organization and helps reason about configuration considerations, reuse, etc. 3) Process View this view supports a run-time view of the system, considering how the system functionality is split into processes and tasks. It helps reason about performance, availability, etc. 4) Physical View this view considers the hardware environment in which the system will be deployed and considers how the software maps to the hardware. b) (2 marks) What is the +1 in this approach? Scenarios are the +1. October 18, 2001 5 of 13

4. (10 marks) As part of an object-oriented design for a graphical drawing editor, similar to the UBCDraw example we worked on in lecture, the following fragment of a class diagram is proposed. Does this class diagram demonstrate "good" object-oriented design? Why or why not? return _w Rectangle -_width : double -_height : double +setwidth(in w : double) +setheight(in h : double) +getwidth() : double +getheight() : double _w = w _h = h return _h Square Rectangle::setHeight( h ) Rectangle::setWidth( h ) +setwidth(in w : double) +setheight(in h : double) Rectangle::setWidth( w ) Rectangle::setHeight( w ) This design does not demonstrate good design according to the principles we studied. In particular, the design breaks the Liskov substitution principle. The problem is the redefinition of the setwidth and setheight methods in Square. These methods have a weaker postcondition than their counterparts in Rectangle. The postcondition of setwidth in Rectangle is that after running setwidth, the_width variable will have the value of the given parameter and the _height variable will be unchanged. In Square, setwidth changes the value of _weight and _height! As a result, a Square cannot be substituted everywhere for a Rectangle. Consider the following code void f( Rectangle r ) { int i = 2; int j = 3; r.setheight( i ); r.setwidth(j); assert ( r.getheight() == i ); assert( r.getwidth() = j ); } Square s = new Square(); f(s); --- the first assert will fail because the call to setwidth changed the height value as well. October 18, 2001 6 of 13

This page is intentionally blank. October 18, 2001 7 of 13

5. (Total: 15 points) We studied three design patterns. A sketch of a class diagram representing part of the design of an FTP server is given below. Server +run() SyntaxErrorReply Session CommandOKReply +getcode() : Integer +getcode() : Integer +getcontrolconnection() : ControlConnection +getdataconnection() : DataConnection +gettransfercontext() : TransferContext +shutdown() 1 Reply +getcode() : Integer +getmessage() : String Interpreter +process(in : String, in : Session) +getreply() : RepresentationType ControlConnection +run() +send(in : Reply) +close() DataConnection +send() +receive() +close() TransferContext +getrepresentationtype() : RepresentationType RepresentationType TransferMode CommandFactory +getcommand(in : String) +getoutputstream() : Long +getinputstream() : Integer +setstream() 1 Command +perform(in : String, in : Session) UserNameCommand +perform(in : String, in : Session) RetrieveCommand +perform(in : String, in : Session) October 18, 2001 8 of 13

A Server object listens on a defined port for connections from clients. When a connection request is received from a client, a new Session object is created to maintain the session. The Session object creates a ControlConnection (over which commands are sent by the client and responses received), a DataConnection (over which data is sent and received), and a TransferContext object (that describes how the data should be sent and received). The ControlConnection listens for commands from the client and passes each to the Interpreter, which encapsulates the syntax of the command protocol. The Interpreter reads and interprets the command to be executed and requests an object encapsulating the details of that command from the CommandFactory. Each Command class encapsulates the syntax of a particular command. When the CommandFactory returns an instance of Command to the Interpreter, the latter passes the arguments sent from the client and the current Session object to the Command object so that the appropriate actions may take place. The Command object executes the appropriate actions, creates an appropriate Reply, and through the ControlConnection returns the reply to the client. The getmessage operation on Reply encapsulates the knowledge of how to form a message from a code; each subclass of Reply must correctly implement the getcode method to satisfy the protocol setup by getmessage. a. (5 points.) State which of the design patterns we studied are evident in the FTP design and what parts of the design contribute to those patterns. The Command pattern is evident in the Command class and its subclasses. The Template pattern is evident in the getmessage() code of Reply. b. (10 points.) Explain the role of the pattern(s) you identified in the design (i.e., why were the pattern(s) used?) The Command pattern makes it easier to add new commands into the system: the Interpreter will not need to be changed. The Command pattern ensures the implementation of a command is encapsulated. The Template pattern captures the algorithm of replying and helps make sure it is adhered to consistently. October 18, 2001 9 of 13

6. (Total: 10 points) Object-oriented Design Fundamentals a. (3 marks) Most object-oriented designs include associations. What is an association and why are associations used in an object-oriented design? An association is a relationship between two classes. Associations are used to represent data relationships (i.e., for every object of one class there are n objects of another class) and to represent interactions between classes. b. (2 marks) Do common object-oriented languages, such as C++ or Java, support the direct implementation of an association? If so, how? If not, how are associations implemented? No, one must map an association onto object references in each (or one of) the classes depending on whether it is a bi-directional (or unidirectional) association. c. (3 marks) Most object-oriented designs describe invocations. What is an invocation and why are invocations used in an object-oriented design? An invocation refers to the execution of an operation on an object (e.g., calling a method on an object). d. (2 marks) Do common object-oriented languages, such as C++ or Java, support the direct implementation of an invocation? If so, how? If not, how are invocations implemented? Yes. Method calls provide direct implementation of an invocation. October 18, 2001 10 of 13

7. (Total: 25 points) Compare and contrast the pipe-and-filter and implicit invocation styles according to the following criteria: kinds of components, kinds of connectors, control topology, binding time of control, the flow of control and data, and the purported benefits of the style. Pipe & Filter Implicit Invocation Components Filters Arbitrary (processes, objects, etc.) Connectors Pipes Events or messages Control Topology Acyclic (accepted arbitrary although its not quite right) Arbitrary Binding Time of Control Invocation or run-time Write-time, compile-time, run-time (full marks if you just said run-time) Control Flow Data Flow Benefits Filters run asynchronously: A Ftiler starts when data arrives. Control follows data (and vice versa) Data follows control. Continuous data flow, high or low volume. Reuse (of filters) and modifiability Components register interest in events. They are invoked when the event is announced. May not flow in the same direction as an event. Typically sporadic, lowvolume data Modifiability October 18, 2001 11 of 13

UML Reference Class1 Class Class2 Class3 Generalization: Class3 inherits from Class2 Class4 Class5 Dependency from Class5 to Class4 Class6 1 Class7 Composite Aggregation: Class6 aggregates Class7 Class8 Class9 Aggregation: Class8 aggregates Class9 Class8 Class9 Association between two classes October 18, 2001 12 of 13

October 18, 2001 13 of 13 Student ID#: