Stack Task

Using the stack task to its fullest potential means:

  1. Implement the stack the simplest (not the laziest) way using a simple array. Although its is not the smartest way, it allows us to address more aspects of unit testing. Choose a smallish (e.g. 4 or 8 elements) storage size for the stack.
  2. Test each method with its normal usage.
  3. Test abnormal usage such as popping from an empty stack or pushing onto the stack when the storage space is exhausted.
  4. Introduce throwing of exceptions to 'properly' handle the abnormal usage. What kind of exceptions do you choose? Checked or unchecked?
  5. Handle the overflow (storage is exhausted) by making the stack implementation to 'grow' its storage, still using the array implementation.
  6. Additional questions: Is your implementation threadsafe? How would you determine the performance penalty, if you had to implement a thread safe variant?

Pieter van den Hombergh
Last modified: Tue Feb 21 11:43:43 CET 2006