Thursday, January 23, 2014

Object-Oriented Programming

Hello all! This will be the first in a series of weekly slog posts for CSC148 at the University of Toronto. This week I will briefly discuss object-oriented programming.

Object-oriented programming is a programming paradigm which involves creating 'objects', which, for all intents and purposes can be considered to mimic real world objects. A programming object can be considered to be something like a specialized virtual machine. It has it's own properties and can perform it's own operations independent of other objects. Once a blueprint or template for an object (known as a class) has been created it can easily be duplicated as many times as is necessary.

My first introduction to objects was in CSC108 at U of T and was somewhat basic. Since beginning CSC148 I would like to think that I have developed a more complete understanding of this programming paradigm and it's benefits and uses. We have done some lab work on Objects which has been helpful. For instance, during our first lab we worked on designing and implementing a class that would take care of cataloging the words and the frequency with which they appeared in a text file. My partner and I had no difficulty writing the skeleton (basic outline) of the class, although we ran into some troubles when trying to implement a top n word count method. During our second lab we worked again on implementing our own class, this time working with abstract data types like a Stack and a Queue. I found this to be quite helpful as it gave me chance to get used to thinking of using inheritance when writing a class that is very similar to another class. Inheritance can be used to 'pick up' existing methods and attributes associated with a parent or super class.

To me, the usefulness of objects seems to stem from the fact that they allow the programmer to be 'lazy'. That is, they allow you to avoid re-writing code by re-using existing classes. Once a class has been written, there is no need to write it ever again! A fringe, or perhaps an even greater benefit is the ability to revise code that has already been released without causing any catastrophic error on the client side of things. One example of this was discussed during lecture; we had already (hypothetically) shipped our stack code, and needed to made some changes after the fact.

At first I struggled to implement objects because they were so different from what I was used to (mostly procedural programming). I had conceptualized programming as telling the computer directly what to do, not creating virtual objects. However, with some practice they are becoming more and more intuitive.

I am looking forward to learning more about objects and improving my abilities using the object-oriented programming paradigm in the future.

No comments:

Post a Comment