ICS 52 - Introduction to Software Engineering
Winter, 2001

Final Exam

  1. (5 points each, 25 points total) Define each of the following terms, as used in software engineering.
    1. Test case
      A function/method to test, an input, and an expected output.

    2. An error (in testing)
      A flaw or defect in the source code.

    3. Edge coverage criterion
      Selecting a test set such that, after each test case in the test set has been executed, each edge in the program's control flow graph has been executed at least once.

    4. Software design
      A system decomposition into modules. A description of what each module is intended to do and of the relationship between modules. is correct.

    5. Testing oracle
      A mechanism for determining whether the outcome of a test is correct.

  2. (10 points) Draw lines between the kind of testing on the left and the corresponding description on the right. (Two descriptions don't correspond to testing types.)

    big-bang doing all integration testing at once
    functional based on what a program is intended to do
    regression checking for degradation due to modifications
    in the small testing individual software components
    structural using the source code to derive test data
    (no match) used only when the input is described by a grammar
    (no match) based on the complete coverage principle

  3. (7 points) Recall the article ``The Cathedral and the Bazaar.''
    1. Briefly describe the ``cathedral'' style of software development.

      Software is released only at long intervals, after much effort has been expended finding and fixing bugs. Good for initial development.

    2. Briefly describe the ``bazaar'' style of software development. Software is releases often; users are partners in software development; anyone can contribute and find or fix bugs. Not appropriate for original development of system. Open-source software style.

    3. Choose one software quality (from Chapter~2) or software engineering principle (from Chapter~3), name it, and describe how the cathedral and bazaar styles differ in terms of that quality or principle.

  4. (8 points) The book says that stepwise refinement ``fails to scale up to systems of even moderate complexity.'' Identify and briefly explain two of the shortcomings of stepwise refinement.

    (We scored this question quite strictly, not giving credit for answers that didn't directly address the particulars of stepwise refinement.)

    (See pp. 112-113.)
    Subproblems tend to be analyzed in isolation.
    No attention is paid to information hiding.
    No attention is paid to data.
    The top function may not exist.
    There is a premature commitment to the control structures that govern the flow of control among modules.

  5. (8 points) Draw and label a diagram of the spiral model.

    Two points for each quadrant, plus one point for the spiral, if that didn't put the total over 8.

  6. (12 points) You have been assigned to design test cases for black box testing of a function called StringToInt. The function takes a String as its parameter and returns the int with the corresponding value. For instance, StringToInt("-35 ") returns -35. The function throws a NotAnIntException if the parameter is invalid and the function cannot make the conversion.
    1. For this function, what is the input domain? Also, describe the format of valid inputs.

      (Of course you should read the answers below as a sample, not the only correct possibility.)

      Strings starting with 0 or more spaces, followed by 0 or 1 dashes (minus signs), followed by 1 or more characters in the range '0' through '9', followed by 0 or more spaces.

    2. For the input domain you defined in (a), name a specific basis for dividing the domain into subdomains.

      Number of leading spaces. Assume that otherwise the String is correctly formatted.

    3. Using the basis from (b), name three or four subdomains.

      1. No leading spaces.
      2. One leading space.
      3. Between two and 10 leading spaces.
      4. More than 10 leading spaces.

    4. For each subdomain from (c), give a test case input and the expected output.

      1. Input: ``193''. Expected output: 193.
      2. Input: `` 193''. Expected output: 193.
      3. Input: ``   193'' (three spaces). Expected output: 193.
      4. Input: ``                    193'' (20 spaces). Expected output: 193.

  7. (12 points) Consider the function sort3, which sorts in place an array of 3 ints. If the array length is not 3 it is supposed to leave the array unchanged. Assume that the values of the array are displayed on the screen after sort3 returns.
    	public void sort3(int[] n)
    	{ if (n.length != 3) return;
                
    	  // move smallest element to position [0] if it's not already there
    	  if (n[1] < n[0] || n[1] < n[2])   // n[1] smallest?
    	  {
    	     int temp = n[0]; n[0] = n[1]; n[0] = temp; // swap n[0], n[1]
    	  }
    	  else if (n[2] < n[0] && n[2] < n[1])  // n[2] smallest?
    	  {
    	     int temp = n[0]; n[0] = n[2]; n[2] = temp; // swap n[0], n[2]
    	  }
    	  // move next smallest to [1], if it's not already there
    	  if (n[2] < n[1])
    	  {
    	     int temp = n[1]; n[1] = n[2]; n[2] = temp;  // swap
    	  }
    	}
    
    1. One error in sort3 is the statement n[0] = temp;. There is another error -- what is it?

      (n[1] < n[0] || n[1] < n[2]) should be (n[1] < n[0] && n[1] < n[2]).

    2. The method could generate a fault that does not lead to a failure. Explain how, specifying the parameters, the fault, and why no failure occurs.

      Calling sort3 on the array [10, 20, 30] causes the first swap to be executed, which is incorrect; However, since the value in position [0] is left in place, sort3 gives the correct output [10, 20, 30].

    3. Give an example of input parameters that cause a failure, and say what the failure is.

      [30, 20, 10] becomes [30, 10, 20]; it should become [10, 20, 30]. Since the values are output to the screen, it is a failure.

  8. (3 points) Which of the following is a reason why the path coverage condition is almost impossible to achieve? (Choose one.)
    1. The number of execution paths is very large. (see p. 277)
    2. The number of nodes in the control flow graph is very large.
    3. Each test case can traverse at most n paths, where n is the number of nodes in the control flow graph.
    4. Some loops in the program would have to be skipped.
    5. Test cases can only test reachable statements.

  9. (3 points) When a module M is decomposed into other modules, we say that these are used to (choose one)
    1. implement M. (see p. 64)
    2. design M.
    3. interface M.
    4. export M.
    5. abstract M.

  10. (3 points) Which of the following adjectives does not describe the waterfall model, according to the textbook? (Choose one.)
    1. Cyclic. (see p. 371)
    2. Rigid.
    3. Monolithic.
    4. Linear.
    5. Ideal.

  11. (3 points) If the steps of a software process, and its current status, are well documented, then the software development process is (choose one)
    1. visible. (see p. 35)
    2. general.
    3. malleable.
    4. rigid.
    5. incremental.

  12. (3 points) Code walk-throughs and code inspections are used primarily for (choose one)
    1. verification. (see p. 299)
    2. determining test cases.
    3. integration testing.
    4. validation.
    5. function point analysis.

  13. (3 points) Configuration management systems address problems that arise from (choose the one best answer)
    1. acceptance testing.
    2. sharing components.
    3. handling product families.
    4. (a) and (b).
    5. (a) and (c).
    6. (b) and (c) (2 and 3 in html). p. 406