Stack Task
Using the stack task to its fullest potential means:
- 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.
- Test each method with its normal usage.
- Test abnormal usage such as popping from an empty stack or pushing onto the stack when the storage space is exhausted.
- Introduce throwing of exceptions to 'properly' handle the abnormal usage. What kind of exceptions do you choose? Checked or unchecked?
- Handle the overflow (storage is exhausted) by making the stack implementation to 'grow' its storage, still using the array implementation.
- Additional questions: Is your implementation threadsafe? How would you determine the performance penalty, if you had to implement a thread safe variant?