Sunday, 9 February 2014

Week 5

Week 5 is the first week where I've had to step outside my comfort zone. The labs are starting to get difficult and the concepts in class are new and harder to grasp. Plus with the burden of Assignment 1 looming on me (and the multitude of tests teachers decide to assign during this week), week 5 was hectic. However there is upsides to this week. What we learned in class this week helped clarify confusion I would sometimes have about errors in my code. An example of this is when I learned about scopes. For example, I did not know that an object created inside a method could not be referenced in the main of the class. This will help me foresee possible logic errors before they occur.


The lab used interesting aspects of recursion. The construction of a GCD function was an application or recursion I never thought of before. Also I can use this function for help in my math problem sets! Also the frozen list will be useful for coding later on in the course (I tend to like my lists to be frozen after referencing them anyway). Thankfully the examples from last week in class helped understand these problems. However these are just more examples on how recursion is a powerful tool. It keeps creeping up in methods I never thought would need it.

The Assignment 1 is so far a daunting task. Last year, we had to do towers of Hanoi as a problem set in our computer science course, so I am familiar with the concept behind the recursion. However, this is a much more complicated version with lots more features implemented. The addition of an extra possible stool makes the problems so challenging to the point where no solutions can be predicted for the larger number of stools. However a close answer should be possible with our knowledge of coding.

Thankfully we have reading week coming up because this week will be a tough one. Not only is there the regular lab and lectures, but the first Assignment due date is coming up and will make the next few days stressful as I scramble to finish it. At least there is no exercise this week!

CSC WEEK 3

This week in class, we focused on the usage of object oriented programming in Python. Since Python is an object-oriented language, this was a very useful way of organizing our code. We used the example of a Stack class to emulate a stack of real life objects. Due to the forces of gravity, a stack is not able to have an item removed from the bottom of it, but only from the top. We incorporated these properties into our Stack class using our knowledge of computer science with new material of classes.

The concept of a class was introduced to us during the first few weeks. It seems a much more logical approach to modelling real life situations than implementing code without any structure. It also is practical if one wants to use a block of code repeatedly, since all you have to do is call the class instead of rewriting lines upon lines of code. I think the implementation of classes in this course will make our future coding easier.

My adjustment to the mentality of object oriented programming was not very difficult. In previous years, I had covered the concept of classes using Java, another object oriented language. This allows me to think in an object oriented manner more easily than a beginner. My most difficult challenge was learning the Python syntax for class manipulation (as well as some more basic syntax). Since I omitted CSC108 from my courses, I had to try and remember my Python from my grade 10 programming class. Furthermore, with the update of Python 3, some syntax has been changed. I have tried numerous times(and I'm sure I will try again) to use the print function without brackets, each time leading to frustration (my tutorial partner can attest to this). Despite this, I think I should be fully accustomed to Python within the next two weeks.

One of the most interesting things about Python this week was the usage of the underscore in variable names. In Java, it was possible to create access modifiers for variables, omitting others from modifying certain variables. However in Python, the underscore is used to signify privacy. It is assumed that the user of the code would have the courtesy to not modify your variables. Another interesting part of Python is the absence of overloading methods. Python does not need to overload methods since the parameters may be of any type (yet you can still use type contracts to denote the type of a parameter). If a parameter is allowed to be omitted, it is declared as a None type in the definition. Another thing I still have to get used to is the concept of self, and having to incorporate it into the parameters. This gave me many errors during the first exercise.

For the first three weeks of CSC148, I feel that I have readjusted to the mentality of a programmer, despite my one year absence from coding. As the course continues to increase in difficulty, I hope I will be able to adjust.

Note to teacher: I am terribly sorry for the late submission of Week 3. I was unaware I had submitted it under the "Pages" category as opposed to the "Posts" one.

Sunday, 2 February 2014

Week 4

4th week in CSC148:

If anytthing the fourth week of 148 has been much like third. The concepts are still fairly easy to grasp and the exercises are still doable without too much thinking. This week we started our first recursion lesson. This was quite an interesting lesson (not just because the pretty pictures we made in class). Recursion proved to be a powerful tool in coding, allowing us to approach multi-layered problems with only a few lines of code.

Basically, recursion is the ability for code to call upon itself. This is useful if we want to have any branching behaviour, such as in fractals. However, it can be use for many more purposes. The example we did in class (aside from the colourful turtles), was finding the maximum of a nested list. We recursively called the function if the item we were inspecting was also a list, returning the maximum of the list each time. This allowed us to efficiently find the maximum.

In terms of the problem set for this week, I found it both challenging and amusing. The challenging part was grasping the concept of exceptions. In Java, we had touched on exceptions, but never in as much detail as we did in class. Wrapping my head around the multiple possibilities of exceptions took some time but I managed to finish the set within an hour. It is cool how you write a class for an exception. It makes it like an exception is its own class. The amusing part of the assignment was to implement the ValueError. The best way (or at least I could find), to satisfy this condition was to actually use a logic error in my code! I never thought in University of Toronto computer science I would ever be asked to purposefully hand in an error!

All in all, I think this week in CSC148 was an interesting week. I can only guess on how we will ramp up the difficulty from here!