Friday, February 12, 2016

Entry 3: Week 5: Of Assignments and Tests

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.

Other than that, this week had passed in the discussion for Assignment 1 and writing Test 1. Test 1 was on Wednesday, and the only regret I had was that I didn't have enough time to check my test over. Since there was a test before our section, we were let in a bit late and I had a class immediately after. With only around 45 minutes, writing all docstring, APIs, and code, proved to be doable, but a bit rushed. I wish I had a bit more time to read what I wrote over and not make any little mistakes. And for Assignment 1, my team and I found it a bit confusing due to the interaction between classes. Currently, we have done the basic classes, and are arguing over the implementation of events. (Although I must state my confusion here... In Java and C++ for code I have done, Events are a part of the standard library in the languages. However, is it simply because we didn't import packages with specific Events so we could define Event as our own class?)

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