Monday, 27 January 2014

LABS AND EXCEPTIONS



The first lab was really fun, we got partnered up with random people according to our birthday dates and it was really cool working together with someone. It also refreshed my memories of programming with python and got me into the programming spirit once more.

In the second lab, we were required to write classes Stack and Queue which turned out to be very useful because it helped me understand better how they work and it will be useful for assignment one (I haven't even started yet).

The previous classes and exercise two were based on Exceptions. Exceptions are basically ways in which we could handle errors in order to make our program keep running instead of crashing. You could also put in short messages to go with the exception which could be pretty useful in certain situations. So, exercise two was basically to familiarize us with the idea of exceptions and how they work.

Tuesday, 21 January 2014

OBJECT ORIENTED PROGRAMMING

         In the past two weeks, we've have been looking at programming with Python from a different angle. We were introduced to something called Object Oriented Programming. This (OOP) is a method of programming that is done by creating objects that relate to the real world.

CLASS
Classes are used to create objects and also methods. Classes have this structure:

def NameOfClass:
     def __init__(self, a, b, c):

I don't fully understand all the concepts here but from what I've learned every class needs to be initialized with the 'init' method above. Also, the first parameter should always be self; self is used to make reference to the new object that was created. The letters a, b and c above are called attributes. There are also method which are functions created under the class that also relates to the way the class functions in the real world.

We also talked about Stacks. I find this concept very interesting. We can add items to the top of the stack and can only remove the last item that was added. It was a little vague at first until I attended the lab this week. Things got a little clearer and I also had fun brainstorming and I began to really understand how a stack works.

This has really gotten me excited for the next few weeks of class. Programming to me is a little technical but fun and definitely worth it in the end.