SLOG # 4
Week 4, and we’re rolling straight into Containers ( i.e., Sack and Stack ), Unit tests, and Linked Lists.
The purpose of this week feels like it’s to nail in the concepts of super and sub classes; a concept that I’m still struggling with, but getting the hang of. I’ve gotten the grind of putting Implementation errors in the superclass and toiling away in the subclass, and it’s efficient—just feels new.
Sack and Stack are both container classes. Stack has a Last In First Out (LIFO) structure, and Sack is randomized. They have similarities in the code—they both need an add method, a remove method, and an is_empty method. Of course, they need the three basics: __init__, __str__, and __eq__, too.
Our class came up with so many creative ways to implement these—Some said we should put add in the super class container, and some said no, we should put it in the subclass. I felt like add could be implemented in the super class; you could add the item to the container, then remove them differently. For stack , you can just pop the last thing that was appended to the stack list, and for sack, you could randomize the list, then pop the last thing out.
( I wonder how “random” Python’s random method is; because in the end, it all boils down to an equation, right? )
Unit tests were a familiar thing from back in CSC108, but I admit I didn’t really study it like I should have. Unit tests provide a reliable and consistent method of testing; you can test for the same cases repeatedly without having to copy paste the code into the console every single time. It’s a bit different than a doc test ( actually, a lot different ) that you need to write a separate python class for it. It’s really efficient.
Unit tests feel odd; probably because they’re semi new material. Tear Down? Set Up? What are these? It’s methods for setting up the test case and cleaning up after it’s done, but the concepts still felt so foreign to me.
Then it was Linked Lists ( We sure were covering a lot of topics this week! ) and the basic intro was that: in python, lists can take up a lot of memory, an large lists may not be able to be stored in computer memory. Linked lists, on the other hand, are “broken up” into nodes and stored separately instead of consecutively, so the computer has more space to operate. Each node has a value and the reference to the next node. The Linked List Node eludes me— And I can’t wait to see how it’s covered next week.
Speaking of next week…
Man, I’m really nervous about the midterm test; writing computer code down into pencil always makes me wince. Mostly because Pycharm’s not there to help me out with its error searching-- but ah, well, a good programmer knows not to depend on its compiler. Tally ho!










