Sunday, 15 February 2015

Week 6

This week we got our term tests back, I did not do very well but I am happy that I passed. This week we started a new concept of trees. A tree is a set of nodes with directed edges between some pairs of nodes. The edges connect the parent nodes and the child nodes, each node has exactly one parent. Trees can basically be used to represent hierarchical relationships, for example, inheritance in a program. Another cool thing we learned was ternary if. We can write long if statements in one line now. We wrote some code for the tree, at first I was quite confused but later when I read it thoroughly I kind of understood the concept. We also did a worksheet in class which had different questions about trees. This week's lab was also based on trees, we had to write some methods for it. The quiz in the end was also about the same topic, I feel I understood the concept more after the lab that's why I was able to easily answer the questions on the quiz. Finally, next week is reading week, I will get some time off to relax and take my mind off the hectic schedule. But, I am not going to miss this opportunity to catch on topics that I don't understand very well like stacks and queues. So, I'm going to take 2 or 3 days off and then start studying.

Object Oriented Programming


Object oriented programming (OOP), as the name suggests, programming based on 'objects', these objects are data structures. OOP contains methods such as inheritance. Inheritance is a method used when creating different classes, it is when a class is based on another  class. There are child classes and parent classes, the child class inherits all the methods and functions from the parent class. In CSC108, we did not see this as much but in this course we have only been working with classes and its methods and so I am quite familiar with this method. Inheritance is very useful since it helps in avoiding repetitive code. Classes contain other methods as well, such as __init__ which is used to initialize an object in the class, __eq__ which is used to compare two objects, __str__ for a string representation of the object and __repr__ for a formal representation of the object.


No comments:

Post a Comment