Friday, 31 January 2014

Week 4: Exceptions, Inheritance, Testing and E2

In the last SLOG, I expressed the difficulties I encountered with exceptions. However, after some practice, this week, I am finding myself quite comfortable with the idea. Exercise 2, which dealt primarily with exceptions, aided in clearing the concept for me. This whole week, I was dreading the exercise, given my limited understanding of the topic, but now, after being done, I am quite pleased with it. Previously, an error in a program would cause the program to crash. However, with exceptions, we can now effectively deal with the errors. We can enable the program to keep running via the try-except method. Something I found really interesting is the ability to create my own exceptions. I have always wondered about invalid input in programs. In CSC108, we were taught to include preconditions in docstring to deter programmers from inputting invalid data. However, that was a mere guideline and did not accomplish much. By raising our own exception classes, we can control the input, as well we provide the user with information on what went wrong.

Another topic in 148 right now is inheritance, which is quickly becoming one of my favorite aspects of programming. Calling on functions in other classes is extremely useful and avoids redundant duplication of code. The lab this week was a lot of fun, as it heavily utilized inheritance. I found myself breezing through most of the lab. However, the part with unittest was a little challenging for me as I spent a large portion of time on it. In lecture, I thought that I understood unittest, however the lab demonstrated that I didn't. Choosing test cases and using assert methods were confusing to me but after struggling through that portion of the lab, I am feeling much more confident in my unittest skills.

This week, we also started recursion. I remember my TA from CSC108 being very excited about recursion and I have been looking forward to it ever since. I must confess that I do not fully grasp it at this point, but I am hoping that with more practice, I will master it.

Thursday, 23 January 2014

Week 3: Object Oriented Programming

Having never done any programming prior to CSC108 last semester, I had gotten very used to procedural programming. Thus, object oriented programming did confuse me initially. Last semester, when we were introduced to classes, I was quite unsure of how they worked, and that was demonstrated very clearly in my final exam, where I very inadequately answered the question about classes. For example, I struggled to understand what self referred to and ended up using it incorrectly numerous times. However, this semester, I am finding the concept of object oriented programming much easier to understand. I now understand that self refers to the object itself and is useful when calling methods and using the class. While I heavily questioned the effectiveness or practicality of object oriented programming last semester, I am finding that I am actually quite enjoying it this semester. Particularly, it is very helpful in organizing large quantities of code. I found the readings provided in the course website to be quite helpful and further readings like those would be very appreciated.

ADTs also helped clear out the concept of OOP to me. The lab this week was very helpful and I enjoyed implementing and using stack and queue ADTs. The similarities and differences between these 2 ADTs, as well as the functionality of ADTs became much clearer to me after this lab. The difference in efficiency between these two ADTs is quite intriguing, in that stacks are generally fater than queues. However, something that I am currently struggling with is Exceptions, which is something we just started in class. I can see the usefulness of exception classes clearly, however it's hard to understand their implementation. In order to clear this up, I intend to do some more practice with exceptions and hopefully, by my next slog, I will have a much clearer grasp on what they entail.