CSE331 Autumn 2011
Software Design and Implementation


Worksheet B: Due Friday December 9, 2011 at 11:29AM

This covers some other material from the second half of the quarter; it should take less time than did Worksheet A.


(2 points each, 20 points total) True or false

  1. A UML class diagram can be executed (just like a Java program can be executed).
  2. Reducing the size of a test case is an important step in debugging.
  3. A good practice is to treat all Java exceptions -- both checked and unchecked exceptions -- in the same way.
  4. An advantage of implementing repOK as a method instead of as an exception is that it allows the implementer of a class to re-establish a broken representation invariant.
  5. The singleton pattern and the ability to define multiplicity in UML provide the same power to a design/programmer.
  6. Representation invariants would be more appropriate to apply to a UML class diagram than in a UML sequence diagram.
  7. Regression testing in principle addresses the removal of tests that no longer apply to a program.
  8. Regression testing in principle addresses the addition of tests for new program features.
  9. Covariance/contravariance are concepts used to define the type system of a programming language.
  10. At run-time, you cannot determine the precise value of a parameter of a generic class.

(5 points) Consider the UML class diagram here of the adapter pattern. Does this diagram represent conventional call-return flow-of-control, or does it represent inversion-of-control? In one sentence, justify your answer.


(5 points) True or false: The primary objective of design patterns is to make it easier to ensure correctness of an implementation. In one sentence, justify your answer.


(5 points) Sketch a UML class diagram that describes the relationships among parties, tables, and the waiting list from A3 (Restaurant).


(0 points) Without running the following Java program, figure out what it does:


public class Qu {
 public static void main(String[] args) {
 String[] str = {
"public class Qu {",
" public static void main(String[] args) {",
" String[] str = {",
" };",
" for(int i=0;i<3;i++)System.out.println(str[i]);",
" for(int i=0;i<9;i++)System.out.println((char)34+str[i]+(char)34+',');",
" for(int i=3;i<9;i++)System.out.println(str[i]);",
" }",
"}",
 };
 for(int i=0;i<3;i++)System.out.println(str[i]);
 for(int i=0;i<9;i++)System.out.println((char)34+str[i]+(char)34+',');
 for(int i=3;i<9;i++)System.out.println(str[i]);
 }
}