CS 509: Design of Software Systems


Solutions for Quiz 3


Introduction

Quiz #3 covered chapters 7, 8 and 9 in the text book. The solutions below either come from student quizzes or are taken directly from the text book, and are examples of "good" answers to the questions. Some of the questions may have alternate answers, so this page is intended as a guide and does not represent the only definitive solutions.

Grade Scale
This quiz was worth 5 points total: 1 point per question, with 1/2 and 3/4 points of partial credit being given where appropriate.

There were 6 questions in all and students had the option of either choosing 5 questions to answer, or potentially gaining some extra credit by answering all 6.

Letter grades were assigned according to this table.
Number Letter Number Letter
> 5 A+ 4.5 B+
5 A 4 B
4.75 A- 3.75 B-
There were no grades lower than B-

Question #1: Briefly define one of the storage management strategies mentioned in the text book.
The three storage management strategies mentioned in the book are listed below. Which strategy to choose for a particular application depends on trade-offs between size of data storage, ease and speed of access, and management features such as multi-user access and recovery from system failures.
Question #2: Briefly define one type of control flow mentioned in the text book.
The three types of control flow mentioned in the book are listed below.
Question #3: What is the difference between application and solution domain objects?
Application domain objects come from requirements and analysis, and represent concepts in the problem domain. Solution domain objects come from system and object design as needed for the eventual implementation, and represent concepts with no counterparts in the problem domain.
Question #4: Briefly define one of the design patterns mentioned in the text book.
The six design patterns covered in Chapter 8 are listed below.
  1. Bridge: Decouples the interface of a class from its implementation by using an abstract interface which may be implemented by several concrete classes, which each provide realizations of the interface for different uses.
  2. Adapter: Encapsulates legacy code not designed to work with the system by providing an Adapter class which implements the interface expected by the client. The Adapter delegates requests from the client to the legacy code and performs any necessary conversions.
  3. Strategy: Encapsulates behavior by decoupling an algorithm from its implementation, or decoupling a policy-deciding class from a set of mechanisms such that different mechanisms can be interchanged transparently at run-time.
  4. Abstract Factory: Encapsulates the creation of a family of related objects while shielding clients from the creation process, and from different platforms that provide varied implementations for the same set of concepts.
  5. Command: Decouples objects responsible for command processing from the commands themselves; encapsulates requests so they can be executed, undone or queued without concern for the content of the request.
  6. Composite: Encapsulates hierarchies by providing a common superclass (component) for aggregate and leaf nodes so they can be treated uniformly through a common interface, and so new types of leaves and aggregates can be added without modifying existing code. The component superclass specifies the services that are shared among leaf and aggregate classes. Aggregates implement services by iterating over each contained component (which can be leaves or other aggregates), while the leaf services do the actual work.
Question #5: What does visibility mean in the context of design? Give an example.
Visibility has to do with the accessibility of a method or an attribute. Any one of the three visibility modifiers used in the book and in Java (public, private, or protected) would be an appropriate example. Public means the method/attribute is accessible by any class. Private means the method/attribute is only accessible within the class where it is defined. And protected means the method/attribute is accessible by the class where it is defined and any sub-class, but not accessible by other outside classes.
Question #6: Briefly define an invariant. What is its purpose? Give an example.
An invariant is a predicate which is always true for all instances of a class. They are used at design time to specify consistency constraints among class attributes and methods, which must be maintained during implementation. For example, in a class which models a fraction, an invariant would be that the denominator's value will never be zero. Another example would be in a class that models a meeting, stating that the end time must be after the start time.

Last updated: 02/28/04 by Diane Kramer