CpSc 372

Exam 2

 

 

Name______________________________________________

 

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

 

  1. We wrote pre/post-conditions for several methods and class invariants for classes. OCL is the object constraint language of UML. Consider the BrickPile class. (the set of Bricks that are to be broken.) The BrickPile is constructed with a list of new Brick objects. The BrickPile keeps the list of Brick objects. Each Brick keeps its own state as to whether it has been broken or not. No Brick object goes away, they just change state as they are hit.
    1. Write an OCL statement for the class invariant for the BrickPile class.

INV:  brickPile.getNumberOfBricks = OriginalNumberOfBricks

 

 

    1. Write pre and post-conditions for the “moved” method. The MovablePiece that is passed as a parameter is a Puck or a Paddle or some other moving object. It knows where it is on the playing field, how big it is, and where it is going.

 

    PRE:  not mPiece = null

  public void moved(MovablePiece mPiece) throws Collision {

    for (int i = 0; i < this.getSize(); i++) {

if(((Brick)_list.elementAt(i)).getBoundingBox().intersects(mPiece.getBoundingBox())) {

                   _fieldPtr.clearCollisions();

    throw new Collision(mPiece,((Brick)_list.elementAt(i)),mPiece.getPosition());

       }

     }

   }

    POST: void OR thrown Collision

 

 

 

 

    1. How does the class invariant show up in test cases?

The class invariant is evaluated before and after each test case to ensure the sanity of the object under test.

 

 

 

 


 

  1. We conducted a design decision regarding saving the state of a game.
    1. One of the design possibilities involved the Strategy design pattern. Mark-up the diagram below to show how it would be used to implement saving the game state. Include appropriate class names, attributes, and methods. 

 

 

    1. When we operate the design decision process, we score each design choice on a set of criteria and then each score is multiplied by a weight. What is the purpose of the weight?

 

The weight reflects the importance placed on each decision criteria.

 

    1. What are the benefits of using a design pattern when planning a design? What are the problems with using a design pattern?

 

Inexperienced designers can make better decisions because of the work of more experienced designers.

 

Design  patterns never exactly fit a problem.

 

 


 

  1. The sequence diagram below illustrates the effects of the timer sending ticks into the GameBoard object.
    1. Give a text description of what the UML sequence diagram “says”.

A timer object sends the tick message to the gameBoard object. In response the gameBoard object sends the move message to a moveableSprite object. The movableSprite object sends itself the computeNew_Location message. The gameBoard object then sends the checkForCollision message to the movableSprite. The movableSprite then sends itself the collideWith message.

 

    1. Which level of use case - abstract, system end-to-end, or functional sub use case - does this diagram represent?

Functional sub-use case. There is no actor shown in this diagram so it represents a portion of a use.

 

 

    1. The message 1:tick is shown as a synchronous message. What difference would it make to the operation of the game (not to this drawing) if the message was changed to be asynchronous?

The arrival of ticks (and therefore the movement of objects) would be less predictable

 

 


 

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

 

public void moved(MovablePiece mPiece) throws Collision {

  ArcadeGamePiece piece;

  boolean collided = false;

  if (!list.isEmpty()) {

    for (int i = 0; i < list.size(); i++) {

       piece = (ArcadeGamePiece)list.elementAt(i);

       if((piece.getBoundingBox()).intersects(mPiece.getBoundingBox()) && piece != lastPiece) {

          lastPiece = piece;

          throw new Collision(mPiece, piece, mPiece.getPosition());

       }

    }

  }

}

    1. Write a set of functional test cases and justify that it is “complete” with respect to some set of criteria. The parameter is a MovablePiece and is as described in #1.b above. Write these as text descriptions rather than Java methods.

The movablePiece != null; pass in a  MovablePiece that overlaps with something on the list ; I expect a Collision exception will be thrown

 

The movablePiece != null; pass in a  MovablePiece that does not overlap with something on the list ; I expect a void return

 

 

    1. Write a set of structural test cases and justify that the set achieves an “every branch” level of coverage. Write these as text descriptions rather than Java methods.

 

No need to, my functional suite will do

 

 

 

 

 

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

Technically, any single test case will do since there is just a sequence of three statements

 

 

 

 


 

  1. Deployment
    1. Describe the difference between installing the java language system and the Eclipse integrated development environment. If one is easier than the other, is there a trade-off in the amount of effort required to get that product ready for deployment?

Eclipse is easier to install because it fixes the CLASSPATH and Path variables automatically

 

It requires additional development and testing time to achieve this

 

    1. How role do self-tests play in the deployment process?

Self-tests are included in the deployment package. They are either run automatically or the installer is prompted to run them. The intent is to ensure that the program is operating correctly.

 

    1. What are the factors that determine how automatic the deployment process should be.

The sophistication of the audience

The cost of the deployment program

The complexity of the program pieces

 

 


 

  1. We discussed the test process working in parallel to the development process. The test process comprises a series of inspections, unit testing, integration testing, and system tests.
    1. What is communicated between the two processes?

The development process produces code and the testing process produces test results that identify faults

 

    1. Where do the test cases used in a Guided Inspection come from?

The use case scenarios

 

    1. A phase description in a process definition has a number of sections: Complete all of the sections below for the unit test phase of the software development process.

Ø        Description – The unit test phase validates completed units

Ø        Responsibility – The developer has responsibility to test what they develop

Ø        Input – completed units; test criteria

Ø        Entry Criteria – unit is ready to be tested

Ø        Activities – test written, tests executed, test results analyzed

Ø        Output – test results

Ø        Exit Criteria – iterate back if too many errors; move forward if sufficient portion passes

Ø        Metrics - %of tests that passed