Monday 16 February 2015

Week 6: Object-Oriented Programming

***Use this for week 7's summary of OOP***

According to wikipedia, Object-oriented programming(OOP) is a "programming paradigm based on the concept of 'objects', which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods." Object-oriented programming is a deep concept that is hard to explain in just a few sentences. Even after my 2 years of experience with programming, OOP is still a confusing topic to grasp. From what I understand so far, a method is a like a function except that it starts with a class parameter, often called self. A class is like a library which contains different kinds of method to that work together to perform a function that the user wants. 


OOP is a very helpful concept in programming, especially when creating games or client code because we can use inheritance or polymorphism to make code from different classes together.
 
Generally, I can use these concepts to write code but sometime's its hard keeping track of how to access methods from classes that are not the main class. Moreover, this week's lab 5 was difficult for me because I was not sure how Tree.py works. We were given many recursive methods that we were supposed to write but since I didn't even understand how the Tree class divides up the children and groups it into nodes, I was not able to write any of functions. It would have been nice if it was more elaborated upon how descendents_from_list(t, L, arity) grouped nodes during our lecture so that I could do a better job on my lab. I hope that this misunderstanding can be cleared up in the next few lectures after reading week.



Sunday 8 February 2015

Week 5: Impressions of Tracing Recursion

As discussed in my earlier post, I didn't really have much of a first impression on recursion because I had already been introduced to this topic in high school. However,  I will discuss my thoughts about the way we learned recursion in class and how it further developed my understanding about recursion. To start off, we were introduced to the idea of recursion through small steps because it can be a rather confusing topic to explain. We first learnt about tracing through simple exercises which asked us to identify the output we would get given a certain argument for a recursive function. In my opinion, tracing was not too tricky until we reached the point where there were several nested lists. I remember having to literally write out each step on paper to actually be able to visualize the steps.

The next part was then to actually understand what was going on with the function itself. For instance, in lab 4, we were given a mystery function with no docstring and we had to fill out the function description, examples and return type ourselves. For me, this part took a little longer than tracing because I had to analyze every line and think about various situations where there could be an error. Moreover, since the beginning in CSC108, I have had trouble figuring out which examples to use for my examples in my docstrings and unittests. No matter how many times I read through the slide about what to look for when writing examples, I somehow still seem to struggle with that part. Hopefully by the end of CSC148, I can overcome this challenge and be master at choosing test cases / examples for docstrings.

The last step in fully understanding recursion was none other than having to write code in recursion ourself. Based on the recursive functions I have written by myself so far,  I would say that it hasn't been too hard. Unlike high school, the explanation of what to expect in our recursive function was very clear and concise. If you just follow the explanation, its very easy to figure out the base case and the recursive case. Hopefully, it stays this way in the future or else I will be spending hours trying to figure out how to write a recursive function like in high school.


Tuesday 3 February 2015

Week 4: Impression of the first few weeks

Having just finished CSC108 a month ago, my transition to CSC148 seemed easier because the materials learned in 108 were still fresh in my mind. In CSC148,  the instructor picks right off from where we finished and introduces us to concepts beyond just loops, if statements and Docstrings. We are finally shown the true applications of programming; to write code that can help simplify everyday tasks. I had been waiting for this moment because having come from a java background, I had experience with writing client code and creating games with graphics. I still remember the excitement of our class when the instructor first drew a turtle on the screen with just a lines of code. It seems that the truly fun (and hard) part of programming is finally starting to unfold.


After having perfected our basics in CSC108, CSC148 puts together all that we learned and forces us to think outside the box. Recursion, for instance, is another way to write code efficiently and reduce the run time of a program. Although I had learned recursion before in java, after listening to the instructors explanation and tracing it, I now see recursion in a new light. Before this, I strongly disliked having to write code in recursive methods because it seemed so complicated to think about where to start and what the base statement should be. But now, I think I am finally beginning to understand the thought process one should go through to write recursive methods. So far, my first few weeks in CSC148 seem to be just about building upon the ideas I have learnt before and applying them to write some simple but time consuming code. The real hard part will start after our first term test- writing code in recursion.