Friday, January 31, 2014

Week 4: Exceptions and reflections



Four weeks have passed since the beginning of the winter term, and I have learned a lot from CSC148 in this short amount of time. Although nothing really challenged me this week, or any material up until now to be honest, I really do feel like I learned a lot from going to class, attending labs, and doing exercises. The concepts are so much easier to understand when actually applying it through labs and exercises, rather than just doing the readings.
One thing we covered on about in the past week is handling exceptions; an exception object is created whenever a runtime error occurs, it interrupt the program and print out on which line the error is found. It is very useful for debugging a program. Exceptions can also be used as pseudo if statements when using in conjunction with the try statement. With the except clause, user can raise the exception as it is generated, interrupting the program to warn the user of the error; or one can follow up the except keyword with name of the exception, as long as the error generated match the one you named, the program would continue running with the statement within the except clause without interruptions.
This technique was greatly enhanced in this week’s exercise, in which I had to raise and catch various different exceptions, including creating my own exceptions with its own customized message. I am really appreciating these exercises, especially with auto-testers to check for errors, to further improve our learning experience.

No comments:

Post a Comment