System Analysis and Design

Exercise No. 1

Due on December 16th by 5pm

 

Read the following article, which all the questions refer to: http://www.elj.com/eiffel/dbc/

  1. External quality factors are those whose presence or absence can be detected by the software's users; internal factors are those that can only be seen by developers. Which of the listed factors are external and which are internal?
  1. What are the advantages and disadvantages of using lines of code (KLOC) as a measure of software size or complexity? Offer alternative measures.
  1. Give an example of a bug that static checking of software text will never be able to find.
  1. Give one example where preconditions ("require") should be used, and one where input checking ("if not condition then print('Error: ...') end") should be used.
  1. C and C++ provide a library function called assert(condition, string) that halts the program and prints the string if the condition is false. What can't this mechanism do?
  1. Explain the following statement: Violation of a precondition reflects a bug in the consumer (client of the class), while violation of a postcondition reflects a bug in the producer (writer of the class).
  1. Write the specification of a class STACK that will support push, pop, is_empty and count, and is an heir of class MY_DISPENSER presented in section 5.4. Use the notation presented in the paper:

class STACK
inherit
___ MY_DISPENSER
______ redefine insert, remove, count, is_empty
______ rename insert as push, remove as pop
___ end
feature
___ -- this is the part you fill in...
invariant
___ -- you fill this part as well...
end

For each routine, write its signature (type of arguments and return values if any), preconditions and postconditions. Remember that these are also inherited. Also, write the class's invariant.

  1. Write a function BinarySearch(array: ARRAY[G], datum: G): BOOLEAN that implements binary search using a loop (not recursion). The algorithm assumes that 'array' is sorted and returns true if and only if 'datum' is a member of array in O(log(array.count)) time, where 'array.count' is the number of elements in the array. Specify preconditions, postconditions, and the variant and invariant of the loop you use (use the from..until..loop syntax).