Thursday, 19 February 2015

WEEK 6 - Object-Oriented Programming (OOP) Summary

(Note: this will be my topic for Week 7)

YOU DOWN WITH O-O-P? YEAH YOU KNOW ME!

As you can probably guess from above, this week we will discuss Object-Oriented Programming. First off, what is Object-Oriented Programming? Object-Oriented Programming, or OOP, is a concept in which objects are the initial concern. We then use these objects and manipulate them to our needs. OOP has been the primary focus of this course so far.



OOP contains a multitude of concepts. Some of the concepts we covered in this course were creating classes and methods, initializing instance variables, and inheritance. All of these topics were discussed in my Week 4 entry, if you want a more detailed analysis of these topics.

Overall, these concepts were rather easy to grasp. The majority of these concepts, such as classes and methods, were explained in CSC108, so that really helped. With OOP down, I can't wait to begin the next sections of this course.

Monday, 9 February 2015

WEEK 5 - Tracing Recursion + Term Test 1

I know I'm a little late, but better late than never!

This week, we were instructed to discuss about tracing recursion from Week 4. Recursion essentially involves repeating the entire function until each element of the input is reached. If you have ever experienced recursive functions in math, that's exactly what it is - except that we view as Python instead of just mathematical symbols. I have to say, tracing recursive code was pretty simple. At first it was confusing, particularly with list nested in a list, which is nested within another list. However, after doing the examples in lecture and in lab, you start to pick up the format. It's especially helpful that we did not need to write down the function if we already figured out what it does for a certain input. For instance, if we figured out what a function did with a non-list, we would just write the output and skip all the elementary steps. This kept the solution very clean. As well, if the docstring is not given, you can also tell what the function does by simply tracing it and/or picking up the pattern. Overall, with practice, recursion becomes quite simple and actually fun! I can't wait until we learn how to write recursive functions.

Besides tracing recursive codes, we had our first term test. The test was fairly straightforward. It was much like what we had done in lecture and in our labs exercises. This made extremely happy. The test also involved tracing recursion, which also made me shriek inside. We're getting our results this week and I'm hoping that I did well. Wish me luck!

Sunday, 1 February 2015

WEEK 4 - First Impressions

Well, I guess you can say that these first weeks were a little hectic - mainly because our first assignment was due this week. Before I get to talking about the assignment, I should probably discuss the material we covered so far.

The first week was essentially a review of the last weeks of CSC108. We looked at the construction of classes, which was straightforward. The second week of class was when we began to look at new topics. While I was familiar with the method __str__, we learned the difference between __str__ and __repr__. Both are very similar as both return string values. However, we learned __str__ returns a string version of self, while __repr__ returns a string representation of self which evaluates to itself. We then talked about Abstract Data Types (ADTs), which include lists, dictionaries, and stacks. As far as we're concerned, we do not necessarily focus on the implementation of these ADTs, but rather what they return and how we call them. The same week we looked at privatizing variables and functions. We do this by adding an underscore ('_') in front of the variable/function. This was completely new to me and surprising as I thought that all code was privatized. To end the week, we looked at another topic that was discussed in CSC108 which was unittests. As you can see, the pace picked up in the second week. The third week was all about inheritance, raising exceptions, and list comprehensions. Inheritance is essentially creating a superclass and giving all its attributes to a subclass. Raising exceptions allowed us to inform users whether they have done something wrong, such as raising a NotImplementedError. As for list comprehensions, we were basically taught about a for loop that is used for lists and can be written in just one line, which is very useful. If you want the topics in detail, I suggest referring to Timothy's sLOG. It is well detailed and quite amusing. In the end, all of these topics came together for Assignment 1.

Honestly, I found the first assignment very overwhelming. We were given the assignment early on in the semester and once I opened it, a boat load of information came hurling towards me, but I picked out the information that was related to the assignment and found it reasonable (as I thought). I thought I could get it done in the first week, but I realized that I needed to learn new material. Even with the new material we learned, the assignment was very challenging. The information provided was very abstract and ambiguous, which I found odd since CSC165 was all about precision. We were given the opportunity to do whatever we needed to do as long as we met the requirements. This was fairly stressful since I was usually given starter code in CSC108. All of these factors attributed to the difficulty in completing this assignment, However, after rereading (and rereading and rereading) the assignment, going on Piazza, and visiting office hours, a lot of key information was given and specified a lot of confusion I, and the majority of people, had.