Thursday 23 January 2014

Object-Oriented Programming

When I first started with CSC148, it mostly felt familiar until we hit object-oriented programming. The idea of creating virtual "objects" was somewhat harder to visualize in my head due to the fact that the objects created and the way data was stored used more abstract methods. For example when using a class, I felt a little confused with the argument "self" that was put in when the class or its methods were defined. After lots of practice and review, however, I was able to see that the "self" referred to the object itself, so that we could call methods, and use the class. Later on, when we got to ADTs, the general concepts became much clearer to me, and so having to visualize a "stack" or a "queue" was of no problem. The lab that we had this week was also easy to get through, when we had to write the methods ourselves for "stack" and "queue". It was also helpful in understanding the way those two ADTs work and how they are different, resulting in an understanding of why the two ADTs are called "stack" and "queue". The only real problem I had that lab was trying to figure out the efficiency problem of the queue. After some thinking, I quickly saw that the problem was with the pop(0), since after dequeueing, the entire index for the queue would have to shift, resulting in time consummation. In the end, when the TA told us that the solution to fixing this was to create a looped index, I felt rather enlightened since I knew that I would never have thought of something like that. It made me see how much we can do with code, and that to be a good programmer, you really have to think outside the box.