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.

Sunday, 25 January 2015

Opinion: Geeks? Writing? Really?

My use of the term "geek" usually refers to someone who isolates themselves from the rest of the world to pursue a passion in activities that aren't exactly considered mainstream. Such activities include solving Rubik's cubes, deriving equations for fun, maybe some Legend of Zelda, and (coincidentally) blogging. Well, not the blogging you'd expect; maybe more towards following physics forums and constantly answering questions on Piazza. Geeks may be considered highly intellectual and experts in anything that involves technology.

Aside from all of the awesome things about geeks, they do have their flaws. For example, isolating themselves from the rest of the world may cause a lack of social skills when in the workplace or just in everyday life. I don't think it's physically possible for an individual to avoid socializing to others. Even behind a computer screen, geeks must be able to communicate their words effectively so the receiver can fully understand what they are talking about. Being able to communicate an idea to the not-so-geeky people in our lives allow us to work as a team with them to improve either a project or a situation. Unfortunately, we can't always speak using episilons and deltas.

Furthermore, other geeks need to understand what we say as well. As hinted earlier, there are different types of geeks. Physics geeks may have a programming aspect in their next practical (this is very relevant to me!) so their programming friends need to be able to translate from that strange dialect I call Python to a language that not only physics geeks can understand, but one that everyone can understand. Even with only programming geeks, my past partners for assignments struggled reading my code because I resented writing comments out of my own laziness. Fun fact: sometimes professors and teaching assistants like it when you write comments (but not more than around two, as quoted from CSC108); a higher mark is always great!

Assuming that only geeks will read this blog post, here's the general idea I'm trying to convey:

  • Your ideas are important. Sharing them with others will make them useful.
  • You can't isolate yourself from the world forever.
  • #writecomments #yourewelcome

Geeks are usually quick when learning things, so why not invest some time in writing? With this asset, geeks are a step closer to taking over the world.