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.
- You are allowed to use late days, and you are allowed to miss lecture.
However, everybody who attends Friday's lecture and contributes to the
grading will get 5% extra-credit on the worksheet. (Note: extra-credit will
be considered during assignment of final grades only after all the base
grades are assigned. That is, you can not get a lower grade in the course
because you did not do any extra credit, but you may get a higher
grade.)
- We will collect the graded assignments after lecture to record the grades
(and the extra-credit).
- The solutions can be formatted or hand-written; regardless, they should
be legible for the graders.
- Although we clearly will discuss the solutions in Friday's lecture, I
will not be handing out a solution key at least until all students not in
lecture turn in their assignments.
(2 points each, 20 points total) True or false
- A UML class diagram can be executed (just like a Java program can be
executed).
- Reducing the size of a test case is an important step in debugging.
- A good practice is to treat all Java exceptions -- both checked and
unchecked exceptions -- in the same way.
- 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.
- The singleton pattern and the ability to define multiplicity in UML
provide the same power to a design/programmer.
- Representation invariants would be more appropriate to apply to a UML
class diagram than in a UML sequence diagram.
- Regression testing in principle addresses the removal of tests that no
longer apply to a program.
- Regression testing in principle addresses the addition of tests for new
program features.
- Covariance/contravariance are concepts used to define the type system of
a programming language.
- 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]);
}
}