CSE 70 Final Exam Fall 2009

Similar documents
The Strategy Pattern Design Principle: Design Principle: Design Principle:

CS342: Software Design. November 21, 2017

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

EINDHOVEN UNIVERSITY OF TECHNOLOGY

Solution register itself

Study Guide to Exam 2

An Introduction to Object Orientation

Software Engineering

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

The Design Patterns Matrix From Analysis to Implementation

Exam in TDDB84: Design Patterns,

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

SDC Design patterns GoF

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?

1 Software Architecture

Design Patterns Reid Holmes

Chapter 5 Object-Oriented Programming

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

Object-Oriented Design

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

Review sheet for Final Exam (List of objectives for this course)

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

DESIGN PATTERN - INTERVIEW QUESTIONS

JAVA MOCK TEST JAVA MOCK TEST II

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

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

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

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

Application Architectures, Design Patterns

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

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

What are the characteristics of Object Oriented programming language?

CSE 11 Final Fall 2009

CSCU9T4: Managing Information

Compositional Design Principles

CS246 Software Abstraction and Specification Final Examination

An Introduction to Patterns

Design Patterns. (and anti-patterns)

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO

Object- Oriented Design with UML and Java Part I: Fundamentals

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

Introduction to Design Patterns

8. Polymorphism and Inheritance

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Object Oriented Paradigm

Object-Oriented Concepts and Design Principles

CS 11 java track: lecture 3

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Agile Architecture. The Why, the What and the How

Appendix A - Glossary(of OO software term s)

Distributed Objects. Object-Oriented Application Development

COURSE 2 DESIGN PATTERNS

340 Review Fall Midterm 1 Review

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

Object Design with GoF Patterns, continued. Curt Clifton Rose-Hulman Institute of Technology

Topics in Object-Oriented Design Patterns

CS-202 Introduction to Object Oriented Programming

Top Down Design vs. Modularization

CMSC 132: Object-Oriented Programming II

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

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Foundations of object orientation

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

Design Patterns: State, Bridge, Visitor

Inheritance and Polymorphism

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Understading Refactorings

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE. Speaking the Language of OO

Practice Problems. Review, with SOME solutions

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

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

RELEVANCE OF DESIGN PATTERNS TODAY

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson

Java Object Oriented Design. CSC207 Fall 2014

Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7

Cheng, CSE870. More Frameworks. Overview. Recap on OOP. Acknowledgements:

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

CS 170 Java Programming 1. Week 15: Interfaces and Exceptions

Chapter 6 Introduction to Defining Classes

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns

Inheritance, Polymorphism, and Interfaces

Data Abstraction. Hwansoo Han

Introduction to Software Engineering: Object Design I Reuse & Patterns

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

More on Inheritance. Interfaces & Abstract Classes

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Object Orientated Analysis and Design. Benjamin Kenwright

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Object-Oriented Design

Improve Your SystemVerilog OOP Skills

CS 251 Intermediate Programming Inheritance

Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt

CMPE/SE 135 Object-Oriented Analysis and Design

Inheritance and Interfaces

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

Patterns and Testing

Transcription:

Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15 points) Page 9 (16 points) Page 10 (8 points) Total (144 points = 137 base points + 7 points EC [>5%])

More software projects have gone awry (failed) because of A. Lack of funding B. Lack of good software engineering tools C. Lack of testing D. Lack of manpower E. Lack of time Probably the biggest drawback of the Waterfall Model is What does it mean for a design (say, a class) to have high cohesion? A. Methods in a class access data in other classes to provide the glue that ties the whole program together B. Methods in a class work together on a focused task C. Methods in a class are grouped together because they are frequently used methods (object management optimization) D. Methods in a class are grouped together because they provide the same basic function (like I/O) Upfront fully-defined requirements analysis is a big part of a Plan-Driven process like the Waterfall Model. One of the nice features of XP is there is no requirements analysis at all. True or False (Circle correct answer) Which is considered a good and desirable design? A. High cohesion and low coupling B. High cohesion and high coupling C. Low cohesion and low coupling D. Low cohesion and high coupling Extreme Programming (XP) is considered an example of A. Layered Model B. The version of Windows before Vista C. Waterfall Model D. Spiral Model E. Agile Model A key method in the Strategy Pattern is a mutator method for each behavior variable. This allows us to A. Change behavior at compile time B. Change behavior in the interface C. Change behavior at run time D. Change state (behavior) in the object this variable is referencing Objects maintain their own state via (Circle correct letter) A. Their superclass parts B. Their static variables C. Their instance variables D. Their local variables E. Their subclass parts Interface defines messages can be sent to an object while implementation defines messages are coded. (Use the words "how" and/or "what" to answer this question.) 1

The 4 main tenets/features of OOP are Inheritance with a concrete superclass is an example of pure inheritance of. Inheritance with an interface is an example of pure inheritance of. Inheritance with a(n) superclass is an example of a mixture of the two types of inheritance. gives us an is-a relationship while gives us a has-a relationship. To realize the real power of dynamic binding A. A superclass reference must be a concrete class B. A superclass reference must be an interface C. A superclass reference must be an abstract class D. A superclass reference can be any type: interface, abstract class, or concrete class In UML notation for access, public members are notated with a protected members are notated with a private members are notated with a In UML, how is an interface type identified in a class diagram? (Not talking about inheritance here.) What does it mean for a design (say, a group of classes) to have low coupling? A. Multiple classes are coupled by inheritance of implementation low in the inheritance hierarchy B. Multiple classes share a common set of "global" variables for low overhead communication C. Multiple classes rely on the inner workings deep ("low") inside each other D. Multiple classes are not dependent on each other; instead they use a public interface to exchange parameter-less messages (or events) What should you do before a commit? 2

General OO Principles what varies. Favor over. Program to, not. Strive for coupled designs between objects that interact. Classes should be open for but closed for. Depend on. Do not depend on classes. Only talk to your immediate. Don't us, we'll you. A class should have only one reason to. In the MVC architecture, which part(s) plays the Observable? In the MVC architecture, which part(s) plays the Observer? Which is usually considered the better design in the Observer Pattern? A. Push data to the Observer B. Push data to the Observable C. Pull data from the Observer D. Pull data from the Observable In the following Java GUI/Event Handling code fragment: /* Some GUI control object that lays out GUI components */ JButton button1 = new JButton( "Stop" ); button1.addactionlistener( new ResizableBall( /* args */ ) ); public class ResizableBall implements ActionListener { /* Lots of other stuff associated with a ResizableBall */ } public void actionperformed( ActionEvent evt ) { /* Do something with evt */ } Which object is the Observable? Which object is the Observer? What type of testing allows the tester to see the inner workings of the code being tested? What type of testing does not allow the tester to see the inner workings of the code being tested? 3

Given the following method/function: int foo ( int x, int y ) { if ( x >= 25 ) { if ( y <= 50 ) return 1; else return -1; } return 0; } Possible x values: <25, 25, >25, Don't Care Possible y values: <50, 50, >50, Don't Care Possible return values: -1, 0, 1, Don't Care Using the possible values to the right, list the values of x and y and expected return value to perform a full test coverage of this code. x y expected return value Suppose you have the following ant targets in a build.xml script (the bodies of the targets are not important): <target name="come-to-class" /> <target name="get-enough-sleep" /> <target name="get-cup-of-coffee" /> <target name="stay-awake-in-class" depends="get-enough-sleep" /> <target name="pay-attention-in-class" depends="come-to-class,stay-awake-in-class" /> <target name="study-hard" /> <target name="get-good-grades" depends="pay-attention-in-class,study-hard" /> List all the targets in the order they would be run by ant if you entered the command: ant get-good-grades 4

Name at 2 Bad Smells and what Refactoring techniques should be used to eliminate each. Bad Smell #1: Refactoring technique(s): Bad Smell #2: Refactoring technique(s): Given the following Java code, draw the UML class diagrams that model the structure of the code. Do not worry about any of the details in the objects with the exception you do specify the variable ref in class Bar and its relationship with class Bang. Label any lines you draw between class diagrams with "is-a" or "has-a" as appropriate. public class Bang {... } public interface Foo {... } public class Fubar {... } public class Bar extends Fubar implements Foo { private Bang ref = new Bang(); } // other code... 5

Match each pattern with its description: Pattern Strategy Adapter Iterator Facade Composite Observer Template Method A) Wraps another object and provides a different interface to it B) Wraps another object and provides additional behavior for it C) Encapsulates state-based behavior and delegate behavior to the current state D) Wraps another object to control access to it E) Wraps a bunch of objects to simplify their interface F) Subclasses decide how to implement steps in an algorithm G) Subclasses decide which concrete classes to create H) Ensures one and only one object is created I) Clients treat collections of objects and individual objects uniformly J) Encapsulates interchangeable behaviors and uses delegation to decide which behavior to use K) Provides a way to traverse a collection of objects without exposing its implementation L) Encapsulates a request as an object M) Allows objects to be notified when state changes Decorator State Proxy Factory Method Singleton Command Which design pattern is commonly used with the MVC architecture? Which design pattern is commonly used with Java Event Handling? What does MVC stand for? Which design pattern allows for "hook" methods to "hook into" the design at various points? Which design pattern does RMI use? What does RMI stand for? If you have an interface defined in your early design, why might it be beneficial to change the interface into an abstract class instead? What does using an abstract class buy you where otherwise you could just use an interface? 6

To make Christmas look like Thanksgiving, we need to provide an adapter interface A) with the Christmas methods and implement them with calls to equivalent Thanksgiving methods B) that throws an UnsupportedOperationException each time the client tries to use any Thanksgiving method C) with the Thanksgiving methods and implement them with calls to equivalent Christmas methods D) that throws an UnsupportedOperationException each time the client tries to use any Christmas method E) with both Christmas and Thanksgiving methods and implement them with calls to each other's equivalent methods F) that uses reflection to create a Christmas object each time the client requests a Thanksgiving object The OO Principle: "One class, one responsibility" can also mean we want classes to have A) High cohesion B) Low cohesion C) Tight coupling D) Loose coupling The Java enhanced-for loop uses which design pattern? Which OO Principle is also known as the Hollywood Principle? Which OO Principle is also known as the Principle of Least Knowledge (or the Law of Demeter)? Which OO Principle is also known as the Dependency Inversion Principle? Some AC adaptors do more than just change the interface they add other features like surge protection, indicator lights, and other bells and whistles. If you were going to implement these kinds of features, what pattern would you use? A common way to implement a history of operations to provide multiple undo operations is with Which is often considered a better design choice? A) Using a null object B) Using the null reference 7

In the Singleton pattern, we declare all constructors and declare the public simple factory-like methods. Which allows us to change behavior dynamically at runtime? A) Object composition B) Object inheritance The Java I/O libraries are largely based on the pattern. What is the name of the tool that monitors a program execution and tells you where it is consuming time and space? I talked about a standard Java class that incorrectly uses inheritance instead of composition. Which standard Java class is this? In the Web Apps security talk, what was probably the most common security problem? In Java, instance variables live in objects and all objects live in the. Static variables are stored in the type descriptor for that type which lives in the. Local variables and formal parameters live in a data structure called. Interfaces can only contain public methods and public static constants. If a class definition contains at least one abstract method, then the class must be declared to be. Which architectural style is appropriate when several independent program components must access common persistent data? A) Layered B) Pipe-and-Filter C) Shared-Data D) Event-Driven E) MVC Which architectural style is an excellent model for component behavior when the program as a whole transforms a stream of input into a stream of output? A) Layered B) Pipe-and-Filter C) Shared-Data D) Event-Driven E) MVC 8

Which architectural style is a good choice for a program that must react to unpredictable sequences of input? A) Layered B) Pipe-and-Filter C) Shared-Data D) Event-Driven E) MVC Which architectural style is the OSI network model an example of? A) Layered B) Pipe-and-Filter C) Shared-Data D) Event-Driven E) MVC Write a simple svn command to bring the latest changes from a Subversion repository into your working copy. Write a simple svn command to see which files you have locally modified in a working copy of a Subversion repository. Agile development values working software over comprehensive documentation. T or F Agile development values contract negotiation over customer collaboration. T or F Agile development values processes and tools over individuals and interactions. T or F Agile development values responding to change over following a plan. T or F Polymorphism in Java is realized by A) Subclassing from a concrete class B) Subclassing from an abstract class C) Implementing one or more interfaces D) A and B only E) A, B, and C Encapsulation tends to coupling. (increase / decrease) In general, good software engineering principles dictate the use of only and Java access modifiers and not or access modifiers. UML sequence diagrams show inheritance relationships. T or F Polymorphism uses the type of the object at run time vs. the type of the reference at compile time to decide which implementation of a method to bind to. T or F 9

In Java, the 3 keywords to turn off the default dynamic run time binding and turn on static compile time binding are The tool uses a file named build.xml that specifies various that can be invoked. What is Rick's dog's name? In general, creating a new object passing all the initial values in to a single constructor vs. reusing an existing object and calling multiple mutator (set) methods to reset that object's instance variables is A) about the same cost B) creating a new object is more expensive C) calling multiple mutator methods is more expensive In general, a non-synchronized method vs. an equivalent synchronized method is A) about the same cost B) synchronized method is more expensive C) non-synchronized method is more expensive 10