Having no
experience to programming prior to the computer science courses at U of T, I
felt green in CSC108, where we were exposed to Python and had to quickly learn
the basics of programming, focusing on simple functions (I found out later on
that what we were learning was called procedural programming). Now, in CSC148,
it was a change from CSC108; I was bombarded with the many terminologies that I
was not familiar with (ADTs? You mean that security service company, right..?).
One term that came up multiple times (and I know that it will continue to
appear later on in the course) is object oriented programming. At first, this
term didn’t come to me as important nor did I understand what it meant. But it
is in fact, a large aspect of Python.
OOP is
quite self-explanatory. By definition, it is "a programming paradigm that
represents concepts as "objects" that have data fields and associated
procedures known as methods" (Wikipedia). In simpler terms, I would say
that it involves objects and classes. At first, I found this slightly confusing
because I didn't grasp the concept of building a class. Unlike functions which
I was more comfortable with, classes contained new attributes that I was
unfamiliar with such as: the __init__ method, calling methods from other
methods and requiring the argument for self in the object's methods. OOP didn't
seem like it was a very difficult concept to understand yet I was having
trouble with it. It was after some discussion with my friends and the lab
exercise that I came to understand OOP a bit better. It seems to make the code
appear cleaner with the idea of bundling methods together into one object than
that of procedural programming, where functions (rather than methods) are
separately written and can work independently from each other. But it also created the difficulty of debugging because errors are also more difficult to locate in a large class than in separate functions.
My friend
suggested to me that I should think of objects as humans. We all have
characteristics, personalities, and different aspects of ourselves that define
us as who we are. Similarly, classes contain multiple methods that can be
called as well as variables for types (i.e. int, str) that may or may not be
mutated. I also learned that classes, methods, and variables are all objects!
So... objects are contained within objects... like Inception (reference to the
2010 film), but Objection (haha, get it. objection..)!