Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

Similar documents
OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Chapter 5 Object-Oriented Programming

CSE 70 Final Exam Fall 2009

Object-Oriented Design

JAVA MOCK TEST JAVA MOCK TEST II

OODP Session 5a. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

The GoF Design Patterns Reference

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

SDC Design patterns GoF

Design patterns. OOD Lecture 6

Singleton, Factory Method, Abstract Factory, Named Constructor. Using one or more base classes to hide details from the client

EINDHOVEN UNIVERSITY OF TECHNOLOGY

An Introduction to Patterns

What is Design Patterns?

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

CS 520 Theory and Practice of Software Engineering Fall 2018

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

Software Design Heuristics

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

CS342: Software Design. November 21, 2017

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

Object-Oriented Design

Object-Oriented Design

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

Lecture 20: Design Patterns II

GRASP Design Patterns A.A. 2018/2019

Object-Oriented Design

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

CS 520/620 Advanced Software Engineering Spring February 11, 2016

A Hierarchical Model for Object- Oriented Design Quality Assessment

Object-Oriented Design II

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

CHAPTER 6: CREATIONAL DESIGN PATTERNS

Topics in Object-Oriented Design Patterns

Object Relationships

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Second Midterm Review

Foundations of object orientation

CS 520 Theory and Practice of Software Engineering Fall 2017

Logistics. Final Exam on Friday at 3pm in CHEM 102

Object-Oriented Design

OO design. Classes, Responsibilities, Collaborations (CRC) 13/9/1999 COSC

CS 370 Design Heuristics D R. M I C H A E L J. R E A L E F A L L

Testing. Unit, integration, regression, validation, system. OO Testing techniques Application of traditional techniques to OO software

A few important patterns and their connections

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade

Concepts 6. OOAD Part II. BlueJ ex 5.1. OO and inheritance. Intro to inheritance. The DoME project is a database for multimedia entertainment.

Design Patterns Reid Holmes

4.1 Introduction Programming preliminaries Constructors Destructors An example... 3

CSC 301H, Introduction to Software Engineering

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

Modularity Guidelines for design in any programming language

Design to interfaces. Favor composition over inheritance Find what varies and encapsulate it

Java Object Oriented Design. CSC207 Fall 2014

Object-Oriented Software Engineering Practical Software Development using UML and Java

INTERNAL ASSESSMENT TEST III Answer Schema

Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1

Object-Oriented Design

CSSE 220 Day 15. Inheritance. Check out DiscountSubclasses from SVN

CS111: PROGRAMMING LANGUAGE II

1. BlueJ bank example with subclasses of BankAccount 2. Transparency of UML diagram for BankAccount class hierarchy

Introduction to Object-Oriented Programming

A4 Explain how the Visitor design pattern works (4 marks)

Software Engineering

Information Hiding and Aspect-Oriented Modeling

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.

2. The object-oriented paradigm

Object-Oriented Concepts and Design Principles

Object-Oriented Programming Paradigm

Elementary Concepts of Object Class

ECE 3574: Dynamic Polymorphism using Inheritance

Design Patterns and Frameworks 1) Introduction

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

State Pattern. CSIE Department, NTUT Woei-Kae Chen. State: Intent. Allow an object to alter its behavior when its internal state changes.

Object Oriented Programming: Based on slides from Skrien Chapter 2

Student Performance Q&A:

OOADP/OOSE Re- exam. 23 August Mapping marks onto grades. Answers

Design Pattern and Software Architecture: IV. Design Pattern

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

Composite Pattern. IV.4 Structural Pattern

What is Design Patterns?

CS 215 Software Design Sample midterm solutions

Objects First with Java

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

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Object Oriented. Analysis and Design

The Unified Modeling Language. Asst.Prof.Dr. Supakit Nootyaskool IT-KMITL

20.1 Tips for Lab Ex. 6

Object-Oriented Oriented Programming Factory Method Pattern Abstract Factory Pattern. CSIE Department, NTUT Woei-Kae Chen

Software Design COSC 4353/6353 D R. R A J S I N G H

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns

The Strategy Pattern Design Principle: Design Principle: Design Principle:

Modularity!! Guidelines for design! in any programming language!

SOFTWARE PATTERNS. Joseph Bonello

Patterns in Software Engineering

Design Patterns. CSC207 Winter 2017

Design Patterns 2. Page 1. Software Requirements and Design CITS 4401 Lecture 10. Proxy Pattern: Motivation. Proxy Pattern.

Object-Oriented Design

MVC / MVP Mei Nagappan

Transcription:

Object-Oriented Design, IV1350 Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E The exam questions will be a subset of the questions below. The exam may contain one or two (but not more) questions that are not listed in this document. Object-Oriented Analysis 1. Explain the goal of analysis. 2. What is the purpose of a system sequence diagram? 3. Create a system sequence diagram for the following scenario. Scenario will be presented at exam. 4. Explain what a domain model is and what function it fulfills. 5. Describe two methods to find class candidates to a domain model. 6. Specify how you can determine which associations to include in a domain model. 7. Specify a guideline for when an abstraction should be modeled as a class and when it should be modeled as an attribute in the domain model. 8. Motivate why the following abstractions should be represented as a class or why they should be represented as an attribute in the domain model. Abstractions will be presented at exam. 1 (6)

Object-Oriented Design 9. Explain the goal of design. 10. Specify when each of the four different accessibilities (public, private, etc) should be used. 11. Explain the difference between public interface and implementation. 12. Which parts of the code are public interface and which parts are implementation in a subsystem consisting of many classes and interfaces? You shall thoroughly state exactly which classes, methods etc belong to the public interface and which belong to the implementation. 13. The following design has low cohesion. Explain why and suggest a change that will give high cohesion. Also motivate why your change gives high cohesion. Design will be presented at exam. 14. Explain the meaning of encapsulation and give an example of the benefits of encapsulation. 15. Explain the meaning of cohesion and give an example of the benefits of high cohesion. 16. Explain the meaning of coupling and give an example of the benefits of low coupling. 17. Explain why it is not good that a method has greater dependency on another class than the one in which it is found. Also explain how to solve this problem. 18. Explain the meaning of polymorphism. 19. What are the advantages of using polymorphism? 20. Give an example where polymorphism is used. Implement the example in a program, you do only have do code classes relevant for the polymorphism. (10p) 21. Suppose we have a class, call it Server, which has some desired functionality. Suppose further that we want to be able to replace it with another class, OtherServer, which performs the same task but in a different way. It must be possible to switch between Server and OtherServer without having to recompile the classes that call them. Write a program which solves this problem with the help of polymorphism. (10p) 22. Give an example of how you can use an interface to give different classes a common public interface. Write a program that demonstrates how objects of the classes can be called using polymorphism. (10p) 2 (6)

23. The classes Person and Airplane shall have the property print current state on a printer. Show how to design this using an interface for the printout property. Draw class and interaction diagrams, which include the class initiating the printout, and explain the diagrams. Explain the advantage of this solution over a solution without the interface. You do not need to use correct class or method names to manage printouts. 24. a) Suppose we need to store instances of the classes Car and BankAccount in a database. To obtain low coupling it may seem as if the functionality to save an instance should be in precisely those classes, since they have the information that shall be saved. Why is it unwise to place the database calls there? b) Describe a better way to manage the database calls. 25. Explain what a design pattern is. 26. Give a concrete example illustrating the pattern (pattern will be specified at exam). Write a program illustrating the example, you are only required to create classes relevant for the pattern. Explain usage of the pattern in your example. (10p) 27. Suppose we use the Strategy pattern and that classes ConcreteStrategyA and ConcreteStrategyB need to call the client to perform the algorithm they implement. This can be solved as illustrated in the diagram below. What is the reason to write the interface ClientInterface? 28. Suppose we have a Factory that can create objects of various classes. It has methods like: public ProductA createproducta() public ProductB createproductb()... 3 (6)

One problem with this is that every time we want to enable the Factory to create objects of a new class, we have to add a new method. Describe another way to write methods in a Factory, which removes the need to add a new method when the Factory shall be able to create objects of a new class. Explain the pros and cons of the two ways to write a Factory. 29. What is the reason to use a Singleton instead of a class with only static members and never instantiate any object of that class? 30. Is there any occasion when it is better to make everything in a class static instead of making it a singleton? If yes, which? 31. Name three important characteristics of a controller. The question concerns characteristics specific to a controller, it is not correct to answer high cohesion, low coupling and good encapsulation. 32. Why can it cause problems to inherit classes that are not intended to be inherited? Give two different reasons. 33. What conditions must be met to make it appropriate to create a new class hierarchy using inheritance? Neither superclass nor subclass exist before, the question is about designing a new class hierarchy. 34. Suppose you are about to code a particular class and find that you have written another class with nearly the functionality that you now are developing. This means that the two classes in large parts contain the same code, but in smaller parts have different code. Explain in detail why this may be a problem and how to solve it. 35. Suppose you are about to code a certain functionality, and that in a program library you are using there is a class that has almost the sought functionality. Is there any reason to still use that class and, if so, how can you add the functionality it is missing? 36. a) Suppose you have the class hierarchy shown below, how can you change the program to use composition instead of inheritance? The functionality should not be changed. Answer with code using composition. 4 (6)

b) Explain why composition is more appropriate than inheritance if the superclass is not intended to be inherited. 37. Explain why exceptions should only be used when an error has occurred. 38. Explain why errors should always be reported using exceptions, and never using return values. 39. Suppose you have a method (method and its functionality will be specified at exam). Which results shall be return values and which shall be exceptions? 40. Explain when an inner class is appropriate. Give a concrete example of using an inner class and explain why an inner class is appropriate in the example. 41. Suppose a method that searches in a customer register shall be written. The method shall return found customers names and phone numbers. One idea is to have the method return an array of strings where the first element is the first customer s name, the second element is the first customer s phone number, the third is the second customer s name, the fourth is the second customer s phone number, followed the same way by remaining customers names and phone numbers. Why is this a bad solution? Suggest a better solution! 42. Thoroughly explain what should be tested by unit tests. 43. Explain in detail which unit tests should be written for the following code (Code will be given at exam). You do not have to program unit tests (but you may if you wish). Object-Oriented Programming 44. Implement the following class diagram/communication diagram/sequence diagram in correct code. You are required to use the strongest possible encapsulation. (diagram will be presented at exam.) (10p) 45. Explain why duplicated code may cause problems (it s not enough to write that it is almost impossible to maintain ) and how you can eliminate the duplicated code. 46. Explain why long methods may cause problems and how you can split long methods. 47. Why is it inappropriate that methods have long parameter lists? Explain how long parameter lists can be shortened. 48. Suppose your program consists of a few large classes that have many fields with primitive data. Why is this a problem and what can you do about it? 5 (6)

49. Why is it a problem if a large part of the input parameters to methods are primitive data instead of objects. Explain how you can solve that problem. 50. Describe where in the code you would write comments. Explain both why you want comments where you place them and why you do not want comments in other places. 51. Assume that your program contains a user interface where the user enters an ID as a string. Specify why it is a good practice to convert the string to an object that represents the ID. Which object should be responsible for the conversion from string to ID? Motivate! 52. Explain how you want to name packages and how you want to divide the source code in packages. Suppose you re talking about a new program, you do not need to worry about any previous package structure. 53. How would you like to package utility classes? Indicate in which package(s) you would place a class that parses strings and a class that handles URLs. Object-Oriented Architecture 54. Explain how you can use the patterns MVC and Layer to create a good architecture. (10p) 55. Explain which the three different parts of the MVC pattern are, what they should contain and how they can communicate with each other. (10p) 56. Explain why objects in the model never shall call objects in the view when the MVC pattern is used. 57. Explain why objects in the model never shall contain code for receiving input directly from the user when the MVC pattern is used. 58. Describe the integration layer. Explain what functionality should be in the layer and why it is good to introduce the layer. Motivate your answer by indicating which of the properties encapsulation, high cohesion, low coupling, polymorphism and inheritance that are enhanced by the integration layer, also explain how the properties are enhanced. 6 (6)