Tuesday, January 28, 2014

Practical Week 4

Today I did the exception and inheritance (subclass) lab. It was quite confusing at first to try to understand the concept of the super function and try-except catch method. But, with the help of the given 'stack test' example and the help of my TA, I managed to figure what was the lab asking for. It will get messy if the variables messed up (especially when you forgot about the uppercase). The fact that I have taken CSC108 before, we were given a unittest folder. But, now it is up to ourselves to determine our own unittest and what will appear if the code crashed. I will surely practice more on the try-except catch method. It looks cool!

Wednesday, January 22, 2014

Object Orientation (Assigned Topic for Week 3)

          Object Oriented Program (OOP) is a programming paradigm that focuses on object that is associated with one or more methods. The methods of the object usually reflect on how we treat the object in real world. They start with an initializer that uses the method __init__. All the methods of the object uses (self :  'object') as one of their arguments. This enables us to call the method of the object by 'object'.method(), instead of method('object').
          I found out that this topic is interesting because it enables you to create objects that can interact with each other. For, example, in the exercise 1 for week 2, I have to make Dog and Toy objects such that the Dog can play with the Toy. It is really somehow, interactive I would say. The biggest challenge I faced is the concept of OOP itself. At the first practical, I was blur and didn't know what to do. Luckily, the assigned reading and my temporary partner (because I went to the wrong practical room), Matthew helped me a lot with the basic fundamental idea of OOP. Now I realized that the assigned reading is very helpful and essential for any new materials given, so I should be reading it for the upcoming topic which is recursion.

Practical Week 3

This week's practical, I've been assigned to do a driver file that uses a Stack class and a Queue class. It was quite hard at first because I don't really understand the concept of ADT. But, after reading the code in stack.py I began to understand what exactly is gong on. Stack is basically putting new object on top of the deck and pull out the top of the deck when pop. Queue on the other hand is putting new object on the back of the deck but still, pulling out the top of the deck when dequeue. Another major problem I had this week is to cut down the running time for my Queue code. I got the idea of keeping track the head and the tail but I still don't know how to implement it. Hopefully, Piazza and my TA can help me with this.