Software Design (CS223 2004F)

In-Class Exam 1

Distributed: 8:30 a.m., Monday, 1 November 2004
Due: 9:55 a.m., Monday, 1 November 2004
No extensions.

Contents

Preliminaries

There are four problems on the exam. Some problems have subproblems. Each full problem is worth twenty-five points. The point value associated with a problem does not necessarily correspond to the complexity of the problem or the time required to solve the problem.

This examination is closed book, closed computer. However, you may refer to one, hand-written, double-sided, 8.5 by 11 inch page of notes you have brought to this exam.

Please write your name on every page of the exam and on your sheet of notes and submit them together.

You must include both of the following statements on the cover sheet of the examination. Please sign and date each statement. For this exam, inappropriate assistance includes using sources other than your memory and your one sheet of paper.

1. I have neither received nor given inappropriate assistance on this examination.
2. I am not aware of any other students who have given or received inappropriate assistance on this examination.

Because different students may be taking the exam at different times, you are not permitted to discuss the exam with anyone until after I have returned it. If you must say something about the exam, you are allowed to say This is among the hardest exams I have ever taken. You may also summarize these policies.

I will give partial credit for partially correct answers. You ensure the best possible grade for yourself by emphasizing your answer and including a clear set of work that you used to derive the answer.

Problem 1: Documenting Two Dimensional Vectors

Topics: UML, interfaces, abstract classes.

As we discussed, this semester I had my CSC152 class investigate a number of alternative ways to write Vector in Two Space. Here's what we decided:

Use UML to document these decisions.

Problem 2: Introspection

Topics: introspection

In a few paragraphs, describe the key ideas and techniques of introspection in Java. Your description should be clear enough that a classmate who had not yet tried introspection could use it on the take-home exam.

Problem 3: XP Principles

a. List five key principles of XP. Describe each with a sentence of two.

1.

 

2.

 

3.

 

4.

 

5.

 

b. Pick two pairs of principles and, for each pair, descibe how the two principles reinforce each other.

1.

 

 

 

2.

 

 

Problem 4: Testing Sorting Algorithms

Topics: Sorting, testing, JUnit

Suppose we've designed the following abstract class.

/**
 * Things that know how to sort.
 */
public abstract class Sorter
{
	protected Comparator comparator;

	/**
	 * Build a sorter that uses a particular comparator to
	 * order the elements.
	 */
	public Sorter(Comparator _comparator)
	{
		this.comparator = _comparator;
	} // Sorter(Comparator)

	/**
	 * Sort an array of elements in place using the previously
	 * specified comparator.
	 */
	public abstract void sort(Object[] unsorted);
} // class Sorter

Suppose we have also subclassed this class with the Quicksorter class.

Sketch an appropriate JUnit test suite for the sort method in Quicksorter. (If you want to build a more general test suite and subclass it for Quicksorter, that's fine, too.)

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Mon Dec 6 08:33:48 2004.
The source to the document was last modified on Mon Nov 1 06:51:23 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS223/2004F/Exams/inclass.01.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu