CpSc 372

Exam 2

 

 

Name______________________________________________

 

Answer any FIVE of the six questions. If you answer all six, one of them will NOT be graded. All questions are counted the same: 20 points each.

 

  1. We wrote pre/post-conditions for several methods. OCL is the object constraint language of UML.
    1. Write pre and post-conditions for a method that takes a float and returns its square root.

 

Pre: argument >=0

            Float sqrt(float argument)

Post: return = argument^.5

 

 

    1. There is no assignment operator in OCL. Why is that acceptable in a constraint language?

 

A constraint language does not allow side effects so variable values are not changed

 

 

    1. What is the relationship between test cases and pre/post-conditions?

 

The pre-condition establishes the initial conditions for the test case. The port-condition is the expected result.

 

 

 


 

  1. We conducted an inspection of a UML model of the Brickles game architecture.
    1. Describe the differences between a review, an inspection, and a test.

 

Reviews and inspections are conducted before code is written and testing requires code. A review is a high-level examination of the design model/architecture while an inspection is much more detailed.

 

 

    1. Write one of the test cases that you used for your inspection. What is the source of test cases for this type of inspection?

 

Test cases will vary with each student.  The source of the test cases was the use case model.

 

 

    1. List the steps in the inspection process that we followed. For each step, what are the inputs and outputs?

 

-         Review use case model and select representative use case scenarios

Input: use cases  Output: selected scenarios

-         For each scenario, walk through the model action by action. Draw sequence diagram to capture it

Input: scenario and model   Output: list of variances between the scenario and model

-         Create analysis of test failures

Inputs: results of all walk-throughs  Outputs:A report

 

 

 

 


 

  1. To make the GameBoard component truly reusable, the methods that handle events in the GameBoard must be easily modified from one product to another. Here are three options for achieving this: (1) a class that defines event handlers for all types of events. Then an instance of the class is passed to each instance of GameBoard via the constructor. (2) Define a subclass of GameBoard for each product in which the event handler methods are redefined. (3) Define individual classes for each type of event, define an event handler in that class, pass an instance of each class as a parameter to the constructor of GameBoard.
    1. Define a set of criteria for making this decision.

 

Maintainability

Modifiability

Minimal complexity

 

    1. Draw a UML class diagram for each option.

 

 

 

 

 

 

 

 

    1. Select the best option and justify your choice.

 

I choose option 1. The separate event handling class separates concerns. The GameBoard class  has only a single object that is automatically invoked by the event handling mechanism. This approach makes maintenance easier since a single class is the source. The behavior is easily modified by replacing a single object.

 

 


 

  1. Unit testing investigates whether a unit produces correct answers in isolation from all other units. Here is a single method

Public int largest(int a, int b, int c)

{

            if (a > b){

                        if(a > c){

                                    return a;

                        }

                        else{

                                    if(c > b){

                                                return c;

                                    }

                        }

            else{

                        if(b > c){

                                    return b;

                        }

                        else{

                                    return c;

                        }

            }

}

    1. Write a set of functional test cases (in the form of a = , b= , c=) and justify that it is “complete” with respect to some set of criteria.

 

a = 5, b= 3, c=2

a = 5, b= 2, c=3

a = 5, b= 6, c=9

a = 5, b= 9, c=6

 

 

 

 

    1. Write a set of structural test cases, in the same form, and justify that the set achieves an “every branch” level of coverage.

 

a = 5, b= 3, c=2

a = 5, b= 3, c=6

a = 5, b= 7, c=2

a = 5, b= 7, c=9

 

 

 

 

 

    1. What would be required to achieve an “all statements” level of coverage in this method?

 

Any one of the above test cases. The entire listing is one statement.

 

 

 


 

  1. System test appears at two places in the software development process: at model inspection time and after all the code is integrated.
    1. We can do both functional and structural tests on the completed system but we usually do not. Why do we not do structural tests at the system level?

 

The size of a system makes it impractical to attempt to follow a path through the entire program.

 

 

    1. Consider a use case with the following scenarios:

Main scenario – The gamePlayer starts the game, moves the paddle so that the puck bounces on it, eventually the bricks are all destroyed. A dialogue is displayed indicating that the gamePlayer won.

Alternative scenario – The gamePlayer starts the game, moves the paddle so that the puck bounces on it. Then the gamePlayer presses the left mouse button and pauses the game. Eventually the gamePlayer releases the mouse button and continues until all the bricks are broken. A dialogue is displayed indicating that the gamePlayer won.

Exceptional scenario – The gamePlayer starts the game and presses EXIT before pressing START. The game exits.

 

Write one test case for each scenario. Be sure to include the three parts of a test case for each scenario.

 

Main test case –

pre-conditions:           not Game.running()

            inputs:                                    mouse moves

expected result:          screen is clear except for paddle and puck and dialogue

 

Alternative test case –

pre-conditions:           not Game.running()

inputs:                        mouse moves, button press, and button release

expected result:          all movement frozen on the screen; screen is clear except for paddle and puck and dialogue

 

Exceptional test case –

pre-conditions:           not Game.running()

            inputs:                                    mouse moves and a button press

            expected result:          GameBoard disappears

 

 


 

  1. Consider the spiral and waterfall software development process models.
    1. Describe the similarities between the two models.

 

Both contain the same basic activities. Both list those activities in the same order, initially.

 

 

    1. Describe the differences between the two models.

 

The number of time each activity is exercised. 

 

 

    1. The incremental model can be combined with either the spiral or the waterfall models. How are these models different when combined with the incremental model?

 

Each model would develop a segment of the final required functionality using the single exercise of activity and multiple exercise of activity respectively. Then each would take another segment and add it to the first using the same approach. This would continue until all functionality is completed.