Friday, 24 January 2014

Week 3 SLOG: Object-Oriented Programming

As one of the students that had very little experience with computer science problems before last September, I find that I am getting the hang of object-oriented programming. In fact, using Python to write a simple function or class is becoming quite enjoyable. I think structuring a programming language so that concepts can be represented as "objects" or "classes" with certain attributes is a clear way for beginners to understand what is happening when information is processed by a program. The attributes tell us what it is capable of and what its limitations are. Methods are some basic actions you can perform with that object. This makes the objects in a program very similar to objects in real life. For example, an object in real life can be an atom. We know atoms consist of protons, neutrons and electrons. The different numbers of those sub-atomic particles that different chemical elements contain are like 'parameters' for their atoms. How different atoms interact with one another would be their 'methods'.

By using real world analogs, difficult concepts in computer science become less abstract.   This was especially helpful when we were creating the class Queue in tutorial on Tuesday. The name given to that class, "queue", implies the data structure works just like one. We can visualize a queue of people where everyone enters at the "back" of a lineup and exits from the "front". Once the person in front gets out, everyone's place in line shifts forward. This is analogous to the indices of items in a queue shifting down when the first item has been dequeued. The shift in indices was the reason why a Queue takes longer to enqueue/dequeue large numbers of items than a Stack can push/pop. I still have difficulty using proper computer science terminology so I will have to work on understanding object-oriented programming on its own terms and not in relation to something else. 

One thing I don't fully grasp are exceptions. I know that it is an object created in runtime errors, and I believe I can implement an exception in an acceptable way (as in it probably will not crash the computer). However I realize I cannot come up with a good explanation for exceptions which means there is a lot I do not understand about it. If I practice writing code with exceptions in it, or ask other students, the TAs, or my professor, I will gain a better understanding of exceptions and use them properly.