CpSc 372

Exam 2 - Key

 

Name______________________________________________

 

Answer any FOUR of the five questions. Place a large X on the question you are omitting. If you answer all five, the one on which you score the best will NOT be counted. All questions are counted the same: 25 points each. Answer all parts of each question. You will need a picture ID to turn in your exam.

 

You can not have a laptop in the exam. You may have the textbook, class notes, handouts, copies of submitted homework. You have from 2pm until 3:15pm for the exam.

 

  1. UML provides a means of describing a design. The XML and graphical notations are different views but the meanings are the same.
    1. How is abstraction useful when you are creating a design? How does UML support abstraction? How does Java support abstraction?

Abstraction allows details to be delayed until later when they are better known. It also allows a design to be divided into smaller pieces to reduce the complexity of each piece. UML allows models to have varying levels of detail. Java supports abstraction by providing techniques such as “interface” to separate specification from design.

 

    1. Describe the process of making a design decision. List steps sequentially and give pre/post-conditions for each step. Also provide inputs and outputs for each step.

Establish decision criteria

Pre: design goals are set

Post: criteria established and prioritized

Input: goals

Output: criteria

Identify design options

Pre: the context is fully described

Post: a candidate set of options is created

Input: a brainstormed list of options

Output: a refined list of options

Collect data

Pre: sources of design rules that can be used to quantify the options have been identified

Post: each option is evaluated for each criteria

Input: design knowledge and constraints on the current design

Output: scores on each option for each criteria

Analyze and decide

Pre: a complete set of data is available

Post: the single best option is identified

Input: data

Output: a decision

 

 

    1. The three diagrams shown in the picture below are closely related. Briefly describe each of the relationships represented by the arrows labeled 1, 2, and 3. For example how is one diagram useful in validating the other one?

 

1. Each object shown in a sequence diagram must correspond to a class shown in the class diagram/ each arrow in the sequence diagram corresponds to a method defined in the class diagram

2. States are configurations of values of the attributes defined in the class diagram; each transition between states corresponds to a method in one of the classes.

3. The sequence of messages arriving at an object in a sequence diagram must correspond to one path through the state diagram


 

  1. We are using the Model-View-Controller (MVC) architecture as the internal architecture for our plug-in.
    1. We have discussed that the observer pattern is used between the Model and the View. What pattern is used between the View and Controller and between the Model and the Controller? Why is MVC the appropriate pattern and what benefits come from its use?

 

The Listener pattern is used in both cases. The MVC pattern is appropriate because it separates functionally different behavior and reduces complexity thereby reducing maintenance effort.

 

 

    1. The internal architecture of the View must support its role in the observer pattern with the Model and the pattern you identified between the View and the Controller. What are the states in a View instance that support these patterns? What are the pre-conditions for entering each of these states?

 

 

For the observer pattern, “dirty” and “up to date” are the two main states. The object must be displaying data to enter the dirty state. The object must have modified the data it is displaying to enter the “up to date” state.

 

For the listener pattern, “listening” and “event handling” are the two main states. The object must be registered with some object to enter the listening state. The object must have received some event in order to enter the event handling state.

 

 

    1. How does MVC illustrate loose coupling? High cohesion? Draw a sequence diagram for one of the scenarios for our system that involves at least two of the three architecture elements. How can a designer look at these sequence diagrams and have some idea about the coupling and cohesion of the architecture?

 

M and V show loose coupling by having public functions by which the two communicate with each other. Each exhibits high cohesion by having a very specific responsibility in the architecture.

 

The number and type of messages between two objects that are associated shows the level of coupling. The number of messages between an object and all of the objects it composes shows the degree of cohesion. 

 

 

A sequence diagram of the Model / View notify/update cycle would work for this.

  1. Designing a solution involves a number of factors.

 

    1. How do we take a set of requirements and design the “user experience?” List a set of steps.

Take each actor, determine their level of experience, consider their entire set of uses, and design controls that are appropriate.

 

 

    1. Describe at least three steps in a design process that begins with an analyzed set of requirements and ends with a detailed design model. For each step list pre and post-conditions, the purpose of the step, and the inputs/outputs of each step.

 

Identify the responsibilities

Pre: requirements have been reviewed

Post: all requirements are covered by some responsibility

Input: requirements

Output: set of responsibilities

Identify design patterns that address the constraints on the design

Pre: a catalog of patterns is available

Post: selections have been made

Input: all design constraints and product responsibilities

Output: selected set of patterns

Use the patterns to distribute responsibilities

Pre: patterns are available

Post: the monolithic design has been decomposed

Input: the patterns and the responsibilites

Output: a design that has several pieces, each of which has responsibilities

Validate the design

Pre: design has been completed

Post: design satisfies constraints

Input: a tentative design

Output: list of design defects

 

 

 

 

    1. Apply the expression “Form follows function” to your answers of a and b. How is our approach to design shaped by this expression?

We begin design by first looking at the requirements, which specify function. Once we have that incorporated then we worry about the user experience.

  1. Eclipse has several mechanisms that support the various pieces of the design we have developed for our product.
    1. The plug-in.xml file supports a lightweight means of specifying some of the functionality needed for our product. Which of our architecture divisions does it support? How? Why is this approach the appropriate type of support for this portion of the architecture?

 

The plug-in.xml file supports the C portion of MVC the most. It allows you to define new menus, editors, etc. MVC supports this by isolating into C those aspects that are likely to be platform dependent. This is appropriate because we are more likely to want to change the user experience from one version to another than change the definition of an orthogonal array.

 

    1. What structures and techniques imposed by Eclipse encourage loose coupling? Give specific examples of how the Eclipse architecture facilitates extensibility and maintainability.

The extension points and use of dynamically interpreted XML encourage loose coupling. The “editor extension point” supports the addition of editors. The partitioning of responsibilities into small plug-ins supports maintainability.

 

 

    1. Below is a possible constructor for the ProblemArray class. The InputDialog widget is used to get the number of factors and then the number of levels for each factor and the fields are initialized. What is wrong with it from a design perspective (not an implementation perspective)? What needs to be done to improve the design?

 

public ProblemArray(){

InputDialog id = new InputDialog(window.getShell(), "OATS Configuration","Enter Number of Factors", "0",null);

      id.open();

      numFactors = new Integer(id.getValue()).intValue();

      for(int i=0;i<numFactors;i++){

id = new InputDialog(window.getShell(), "OATS      Configuration","Enter Name for factor "+i, "0",null);

            id.open();

            name = id.getValue();

            vectorOfNames.add(name);

            id = new InputDialog(window.getShell(), "OATS Configuration","Enter Number of Levels for factor "+i, "0",null);

            id.open();

            item = new Integer(id.getValue()).intValue();

            vectorOfLevels.add(new Integer(item));

                 

      }

}

This constructor combines representing a problem array and interface issues. The interactive portion should be in one class and the representation of the problem array in another.

  1. We have used several design patterns in our design of OATS.
    1. We used the decorator pattern in our implementation of the ViewedArray. How was this implemented? What did this do for our design?

 

Each array was wrapped in another object that added the ability to be displayed to the basic array class. It was implemented by subclassing the basic array class to define the decorator and then having the decorator aggregate an instance of the basic array class.

 

 

 

 

    1. We used the factory method pattern to produce instances of the various types of arrays in the model. Why? How does it work?

 

We used the factory pattern because this abstracts the availability of a particular set of behavior from exactly which class provides it. Client classes do not invoke the constructor directly, rather they call a method whose implementation calls the constructor on some class (which may change over time).

 

 

 

    1. Use the GQM technique to define a measure that would help a manager who wants to know how much progress is being made on a project. Show all three steps.

 

Goal:  To complete an assigned project

Questions:

1.      How much of the work has been done?

2.      How much of the allotted time has past?

 

Metric:

1.      % of modules that have been developed

2.      compare % of modules completed to the % of time that has elapsed