Thursday, 30 January 2014

Week 4: Exceptions

In the previous week, we learned to write exception classes and try statements. We were able to implement this knowledge into this week's exercise, where we wrote our own exceptions (E2Error, E2OddError) for our try statements. I had a lot of trouble understanding the three components of a try statement and in which order they execute. Because of this, I had to do a lot of research before figuring out how to complete the exercise. This frustrated me because the examples I found online were not completely relevant to the tasks we were given, but in the end, I managed to figure it out. A try statement includes three components: try, except, and finally. The code under the try clause is executed first, and if an error is detected, it will execute the except clause of whichever error occurred. The finally clause executes whether or not an error occurs.

Another area that I had difficulty in was writing exception classes, or rather, implementing them into my except clauses; however, I was able to learn how to do this, which is why this is one of my biggest achievements this week.

Tuesday, 21 January 2014

Object-Oriented Programming

Object-oriented programming (O.O.P.) creates, as the name implies, objects which contain certain attributes and functions. This differs in what we learned in CSC108, in which we learned mainly modular programming, which consists mostly of executions of multiple functions. In doing a bit of research, I found that O.O.P. contains five defining points: encapsulation, inheritance, polymorphism, interface and abstraction. This means that an object, created under a class, contains the data and methods in which to alter or display its attributes and that, though there may be the same method names for separate classes, each method will perform a different task depending on which class it is executing under. In this way, O.O.P. can handle the complexity of programs; however, there are downsides to using object-oriented programming. These include that they require a greater amount of time and effort and are bigger in size compared to other programs.

I have little experience with O.O.P. as 108 mainly taught modular programming, but I hope to learn more about and become better at this type of programming through the 148 course.