When I first heard the term
“object-oriented programming” last semester in CSC108, I was confused as to
what it meant and how it differed from the programming we had mostly been using
thus far.
Over the winter break, I promised
myself that I would review classes and be clear on the meaning of this phrase
as it obviously would be important in the future. Alas, my self-discipline has
never been strong and when the spring semester began I already felt behind.
Thankfully, the first reading
posted for CSC148 explained object-oriented programming extremely clearly, even
for a beginner like me. As opposed to procedural programming that creates
functions to operate on data, object-oriented programming makes it easier to
manage complex computer systems by creating objects in which both data and
functionality are contained.
At first, this seemed like a
small difference, but now after more exposure to object-oriented programming, I’m
surprised at how significant this difference is. By defining objects and the
methods that operate on them, a program better correlates with how humans mentally
think about the world. In class, when we practiced reading a paragraph and recognizing
a class, its attributes and methods, I was pleased at how methodical it was to
translate the words into the outline of a computer program.
The example in lecture (class
Point) was a concrete data type where the professor defined how it was to be
implemented. However, abstract data types (or ADTs) which do not specify
implementation – only operations and what they do – are useful because they can be written once and then stored in libraries for the use of many programmers in many
different ways.
In lecture, I felt like I was
doing a semi-good job of keeping up with the theory behind object-oriented
programming, but when it came around to tutorials I was obviously lacking in my
application skills. On the second lab day, the end of the exercise was to try
and find a solution to make class Queue run faster. Although my partner and I
got the solution, I still had to go home and think about it before I was clear on how the solution worked.
Likewise, I’m feeling frustrated
with understanding inheritance. In one of the readings, inheritance is
described as “the evil forest”. More specifically, it is when an object or
class is based off another object or class. Thus, it allows for the reuse of
code. For example, in class the IntStack subclass inherits from the Stack class
but has been modified so that only integers can be pushed onto an IntStack.
On the other hand, inheritance can
be a dangerous thing if it becomes too complex. With inheritance, the computer
always checks for code in the subclass first and thus it’s possible for some
code to never be executed depending on where it is placed. In lecture, the
professor demonstrated this using Exceptions.
Although I did as recommended
and played around with the code that was uploaded on the CSC148 site, I am
still confused with what “try” and “except” mean. There are many variables to
fool with (the order of the code, commenting, uncommenting, and “raise”) that I’m
feeling lost with what the code means. Tomorrow in class, I will have to ask the
professor to reiterate and clarify his words regarding inheritance.
Overall, three weeks in, I’m not
feeling as behind as I thought I would – and I suppose this is a good thing –
but at the same time I’m certainly lazy and dragging my feet regarding
solidifying this new knowledge. Although the new material is interesting, I have to remember to review my old notes as well (and perhaps even rewrite them in the Python 3 format to familiarize myself with it). I also feel like I've been only skim reading the last assigned readings, thus leaving holes in my understanding of certain concepts, especially Exceptions and composition. Before the course moves on, I have to thoroughly review these readings.
No comments:
Post a Comment