Sunday, 22 February 2015

Object-Oriented Programming Concepts

(Use this for Week #7)

At first, I wasn't sure what to write about. Object-orienting probably means to refer to another object, right? This is probably related to programming as well... Maybe classes?

Looking back at my multiple pages of lecture notes that are based on classes, inheritance, and recursion, I suppose this is what "object-oriented programming concepts" are. These concepts enable objects to refer to other objects such as a child's class would inherit attributes from its parent class, also known as the super class. Maybe this would make sense:

class Child (Parent):
     """ Optional docstring about the child, or at least I like to think it's optional. This child has been 
     born from its parent class, Parent. """

Let's say the Parent class had, for example, blue eyes. (Obviously a class doesn't have blue eyes but this is how I see it.)

class Parent:
     """ Optional docstring about the Parent. """

     def __init__(self):
          pass # this method isn't the point I'm trying to prove, so I apologize for my laziness


    def eye_colour(self):
         print('Parent has blue eyes')

But the possibility of the Child having blue eyes is much lower. A biology student could probably prove this, but unfortunately, I am not one.

class Child (Parent):
     """ Optional docstring about the child, or at least I like to think it's optional. This child has been 
     born from its parent class, Parent. """

     def __init__(self):
          pass


    def eye_colour(self):
         print('Child has brown eyes')

As you can see, the Child class' method eye_colour overrides the Parent class' code. In this example, the child is the subclass and the parent is the superclass.

Although a child inherits features from a parent, it's possible that its DNA would differ from the parent's, thus replacing the parent's features with the child's. From my point of view, object-oriented programming concepts is the way objects interact with each other, just as a parent and child relationship.

Sunday, 8 February 2015

Tracing Recursion

At first, nested functions seemed so confusing to me.  I struggled to understand how a function could use itself to retrieve an answer. Nested lists even caused me trouble; it took me a long time to find where a list started or ended. Nested "anything" was confusing, so you can imagine how terrible learning about recursion was to me.

We began tracing recursion on paper, both in lecture and in labs. I started off evaluating every single call that I could possibly do. After one question, I noticed that I took up more space than I thought, yikes! My TA even told me that I don't have to repeat every single call since apparently, "I had already solved it in a previous statement". So I began again and strangely, it didn't seem so bad. By starting off with empty lists and lists of "depth 0" (whatever that means... I'll learn what it means eventually), I began to understand that I can use the solution that I had just retrieved to find another solution for the next bigger list. Then, you do it again. I was able to evaluate a list of depth 5 without even knowing it.

And so I learned that doing things at the most basic and fundamental level would help me achieve bigger problems. Hey, that's exactly what recursion is!

Monday, 2 February 2015

First Impressions

First impressions tend to be very important on how something will turn out later on. But usually, my first impressions of anything really becomes the opposite of how things end.

For example, I thought CSC108 would be really easy since there were many comments from multiple places (is Facebook a reliable source?) saying that it would be a "bird course" or a GPA booster. Unfortunately, I thought wrong. Since computer science was a completely new topic to me, it was very hard to adapt to. However, I managed to push my way through despite all of my struggles.

After the terrible experience of 108, I expect 148 to be just as dreadful and time-consuming. Before entering the course, I expected completely new topics that I would, yet again, have to adapt to with great amounts of struggle. But it hasn't been the case yet. The past couple weeks have been enjoyable and productive (not including that hectic first assignment...).

I'm especially liking how 148 has labs that have us work on problems based on concepts we learned in class. I also suffer from laziness, so being able to ask the TAs questions during labs makes my learning habits much more adaptable. Hopefully my first impression for 148 turns out like the rest of my first impressions: opposite to what's expected.