Sunday, 15 February 2015

Object Oriented Programming - Tree Class

    This week we continued on the topic of object oriented programming. In both lectures and our tutorial, we learned about the class tree. During the lectures, we were given worksheets and followed Professor Heap constructing functions for class tree. For me this tutorial was the most challenging so far, and I faced multiple slumps while solving the tutorial problems.

    In the tutorial, I was first stuck trying to come up with the algorithm for the first function, list_all. I could do the first two step of the three step procedure and found them straight-forward. However for a while I couldn’t solve the third step, which is to combine my results from the first two steps using recursion. I was stuck on where to implement the gather_list function in the algorithm. First I tried to trace the recursion steps and come up with the algorithm, but this proved to be ineffective. I eventually solved it through constant experimentation. Even though this is a legitimate way to solve problems, I am unsure about the fact that I cannot explain why I would write my code like this. I think I might’ve just gotten lucky. The other questions in the tutorials are much easier after finishing the first one since the gather_list function is implemented the same way. However I got stuck once again on the last function list_to_depth, in which I did not solve in the end because the tutorial session was over.

    In conclusion, I am not confident in my ability to come up with algorithms using recursion. The quiz this week was also the first quiz I wasn’t 100% sure about. I certainly need to practice more during the break, starting the second assignment as well as finishing up the tutorial question.


Sunday, 8 February 2015

First Impressions

* Since last week I talked about recursion (which is supposed to be this week's topic), I am going to discuss last week's topic in this entry.
  In the first few weeks, we learned about classes. Despite having learned about classes in csc108, most of the content, such as subclasses, abstract data types, property, and list comprehension, were new. In lectures, I feel like I "sort of" understand the material, but can’t really tell because of the lack of actually solving problems. While Danny's lecture style is identical to that of csc165, a class I genuinely enjoyed, I found it harder to follow up in the first few weeks. However, I found the tutorials and assignment1 very helpful, since those are the times when we actually do hands on programming. I think for the first two weeks, I was still trying to get used to this new style of lectures (in contrast to csc108, where we had in class worksheets), but now I think it’s a nice balance with the tutorials and assignments. That's mostly my impressions pf the lectures and labs, and for the rest of the entry I'm going to briefly talk about my impressions of each new topic we touched upon.
Classes and Subclasses
CSC148 started with classes, right where we left out in csc108. The only new stuff we learned that I remember is the __repr__ method. The first two lessons on this subject felt like a review session of last semester's material, which was a good transition into a new class. As for subclasses, it was easy to understand

ADT

We were introduced to a new class Stack. We talked about common ADTs that we already know, such as list and dictionary. There may be more about ADT, since our most recent lab was on this subject.

Property
Property is a new concept that we learned about classes. This was not touched upon in tutorials, and therefore I don’t think I fully understand its implementation.
List Comprehension


This is an easy and useful trick that we learned to use instead of writing loops for a list. We learned this in the first lesson, and it was brought up again later on.

Monday, 2 February 2015

Recursion

  Last week we moved into a new chapter: recursion. In class and in the tutorial we did several examples of tracing function that uses recursion. I find recursion a very tricky concept. I have no problem tracing the functions, however I always get stuck writing a function using recursion.

  We were introduced to recursion in three levels. First, we encountered a function using recursion including its docstring. This was simple, since we can “cheat” and know what to expect from the docstring, without perhaps a solid understanding of how the code works. Next, we did several questions in the tutorial of functions without the docstring. This is only slightly trickier, since after a few examples of tracing the code, the logic of the recursion shows up. However, I have difficulties going the opposite direction: coming up with my own code using recursion. I feel like I understand the concept of building and accumulating from the special case (since when tracing, everything eventually reduces to the special case, in most of our cases when the object is not a list), but I think I need more practice.


  It is a relief knowing that in our term test we will only need to trace recursion functions. However, I will have to catch up on implementing recursion in my own code, since it will be a very useful and necessary skill.