CpSc 372

Exam 2

 

 

Name:_______________________________________________

 

Answer any FIVE of the six questions. All questions count the same - plus/minus 20 points.

  1. Forward engineering, reverse engineering and round trip engineering (remember this is the building of the code from design and then changes to the code are automatically propagated back into the design) are all techniques for building products.
    1. Give an example of when each of these types of engineering is useful in a project.
    2. Forward engineering is useful in almost every project. It is useful whenever code is to be developed "from scratch."

      Reverse engineering is useful when you must understand a piece of existing code for which no design documentation is available.

      Roundtrip engineering is useful after most of the design has been completed and you ar making changes during debugging.

    3. Describe how each of the techniques is used.
    4. Forward engineering is a series of steps moving forward from gathering the requirements for a system through design, coding and system test that is repeated until the system is delivered.

      Reverse engineering moves in reverse from code to design representation. It begins with parsing the code and building a representation for the code, usually a graphical representation. The developer then takes the output from the reverse engineering step and studies the representation to perform the needed analysis.

      Roundtrip engineering combines forward and reverse engineering. The engineer begins the construction of a product in forward motion gathering requirements and moving through the steps. Once these steps have been accomplished, as errors are discovered, the code is repaired and the representation is updated.

    5. Describe the role of tools in each of these techniques.

Forward engineering is supported by tools that allow the engineer to build the graphical representation of the product being constructed. These tools integrate a code editor, automatically generate makefiles and compile the product. They provide an environment in which the product can be executed normally or in debug mode.

Reverse engineering tools include parsers and analyzers that read specific programming languages and build the structure of the code in a design representation. The tool includes an editor in which the representation can be examined and modified.

Roundtrip engineering tools essentially combine the facilities of both the forward and reverse engineering tools.

 

  1. Test cases
  1. Below is the specification for a method. Define a set of functional test cases for that method assuming a contractual approach to design.
  2. Pre: switch > 10

    boolean A.chooseOption(int switch);

    Post: if switch <= 20 return true;if switch >20 and switch <= 50 return false otherwise throw exception

    Test case 1 - switch = 11 returns true

    Test case 2 - switch = 19 returns true

    Test case 3 - switch = 20 returns true

    Test case 4 - switch = 21 returns false

    Test case 5 - switch = 49 returns false

    Test case 6 - switch = 50 returns false

    Test case 7 - switch = 51 throw exception

  3. Add the test cases that would be needed if you took a defensive approach.
  4. Test case 8 - switch = 9 throw exception

    Test case 9 - switch = 10 throw exception

  5. What information would you need in order to write structural test cases that is not given in the specification above?

The code

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Making decisions in software engineering is a matter of careful analysis of collected data. Describe in detail the process for decision making. Do not simply describe how we made a specific decision such as the Build/Use/Buy decision. State the process at a level so that it could be applied to any design decision.
  1. Identify the decision to be made
  2. Identify criteria upon which the decision is based
  3. Prioritize the criteria
  4. Identify the choices from which the decision will choose
  5. Collect data for each choice on each criteria
  6. Do the math
  7. Identify the winner
  1. The test cases for a specific component are related to each other. We discussed using three levels of encapsulation for the test-related software: test case, test script and test suite.
  1. In which of those three levels would the construction of the object under test (OUT) go?
  2. Test script class

  3. Where is the decision about whether the OUT passes or fails a specific test.
  4. Test case class

  5. Draw the class diagram for these three classes.
  6. The test cases for one component have relationships with test cases for other components. Describe the role of the test case class in the Parallel Architecture for Component Testing (PACT).

The test case class inherits from either the GenericTestHarness or from the test class for its parent class.

 

 

 

  1. We have begun looking at the design of an elevator system by building a model using the Unified Modeling Language (UML).
  1. Describe how use cases are identified
  2. Use cases are identified by identifying actions of the system (verbs). Begin by identifying actors. Then for each actor, identify the uses made of the system by that actor.

  3. Give one example use case for the elevator system (one main scenario only)
  4. The emergency worker generates a special key event by inserting the emergency key and turning it. The system responds by sending the car directly to the first floor if the car is heading down. The system first stops the car if it is heading up and then sending it to the first floor.

  5. Describe how classes are identified
  6. Classes are identified by looking for concepts (nouns). As each class is defined, new classes are identified from the attributes and actions of those classes.

  7. Draw a class diagram with at least 5 classes. Show the appropriate relationships between those classes.

  1. Jslint is a tool that scans Java code for security vulnerabilities. The tool parses a Java source file into a syntax tree that can be traversed using the Visitor design pattern. A user of the tool can extend the tool by writing additional rules that describe a specific arrangement of Java code and the associated security problem.
  1. In this context, what would be the difference between different visitor classes?
  2. Each visitor class will be looking for a specific security problem.

  3. Use the class diagram in the Visitor pattern handout to draw the class diagram for the essential elements in the pattern as they apply to this problem.
  4. Describe the qualities that the visitor pattern enables in the software.
  5. Extensibility to add new rules

    Modifiability to correct problems with rules

  6. Give at least one reason why Aspect-Oriented programming would not be a good choice to enable the Jslint tool user to add new rules.

The user would have to be able to recompile the code in order to use aspects