I must make a correction to my statement last class. In fact, I do indeed find a difficult aspect for me appearing in this course -- Unit Tests. While it is untrue to say that unit tests are hard in nature (since they have a defined structure so there is little variance in constructing them with code), they are trouble some in their flexibility and range covered.
To test a program fully, all significant cases of a method must be tested. However, what is exactly "significant"? Although we do follow the rule that we should at least test the null (ie 0-sized list) cases, the smallest interesting case, regular cases, borderline cases, and cases where specific variables have values that make a difference in the result, that still leaves a big variation in each one of the cases. Having to consider for all of these is a very good practice, as it prevents unexpected errors in execution, but covering all of them takes a lot of effort. Constructing each unit test also consumes as much time, or even more, than writing the code. Fixing the code for unit test is also difficult, having to consider for all cases and make it still functional. There then exists a problem of how much error prevention is needed in each method -- the open ended question of the type of improper input the end user can enter expands into a completely different universe of possibilities for the program.
As helpful as unit test is, as dreadful as I am to it.
Here's what I learned this week:
List and Linked List Based Queues:
- List based Qs are too slow
- asymmetric
- add @ front + remove @ back: shift right for add, too slow
- add @ back + removed @ front: shift left for remove, too slow
- Stacks are faster: access @ one end = ~same ease of access/speed
- LinkedList Based Qs:
- more symmetric @ both ends
- doubly linked (previous + next) = more symmetric
- if singly linked: add @ back + remove @ front:
- del front = change first
- add back = append
- other way: remove cannot do "previous" of back
- if doubly linked: both direction works
- though slower @ middle
Linked Stacks:
- Instead of append (like Q), prepend (to invert order)
- add front, remove front
- not necessarily slower than stack
No comments:
Post a Comment