Thursday, 23 January 2014

Object Oriented Programming

     Well, this is my first SLOG so I'm not exactly sure how to start this off but I guess I'll start talking about how I feel about the course work we've done so far on object oriented programming. To be honest, the first 2 weeks of lecture and lab were pretty easy for me. The classes and methods that were taught to us I learned in both the end of CSC108 and I spent half an high school semester learning about object oriented programming. There were a few minor differences from the things I learned from high school since we programmed in Java but the ideas were more or less the same. Finally using objects again, it made me realize how much easier it is to associate multiple things to one object than to try and put them all together by having them at the same index but in different lists. Creating the methods in Python are slightly different than how we did it in Java and the first week was a bit challenging but after going through a few more examples in the lecture and making a few methods of my own for the Stack class, I feel like I've gotten the hang of the basics in object oriented programming in Python.

     Now then, about the assignments and labs we've done up to this point, they honestly weren't that hard yet. The square root assignment was a bit weird because we had to use the Newton Method but after a bit of thinking and trial and error, it only took me a few minutes to code. The dog and play classes were extremely easy as I already understood how creating classes and their methods worked so that wasn't a huge challenge for me. For the labs, I honestly found the first lab a lot more confusing than the second one. The second one was dealing with stacks and queues and back in high school, we actually did this already, making a stack and creating its methods and same with queues. The slight difference is that our stack and queue sizes were initialized at the beginning and the size of the stack or queue could not be bigger than what we initialized it to. Also when I talked to the T.A. about what I knew, he told me the queue would read just from the "head" of the queue to the end. In Java, we had both a head and a tail since the size was predetermined and the tail would go back to the beginning if we tried to add anymore to the queue. The queue we made read from head to tail since we were reusing old spaces in Java. Well that's enough about the second lab, in the first lab it wasn't really hard, rather it was hard to follow what exactly the lab was asking us to do. Me and my partner ended up getting stuck creating one of the methods and we never got time to reach the second activity sadly. The method we got stuck on we solved eventually but it took us way too long and in the end, the T.A. showed everyone how we could have done it a lot more simpler. It really showed me and my partner how thinking about how to do something in different ways can lead to a much, much easier time coding. Overall, the activities and labs for the first few weeks regarding object oriented programming weren't that hard and was a nice review.

     I never actually talked about object oriented program in the first few paragraphs so I'm going to be summarizing what I know and learned about it from the lectures and notes we took. Object oriented programming is using objects which contain data types associated with each object and a set of procedures or methods that can be used on that object to do certain things like modifying the data or retrieving it. An object is a single instance of a class which is initialized by passing parameters into an __init__ method. If no __init__ method is created, then the object will be an instance of that class with no data currently in it. Afterwards, methods are created in order to perform certain actions on that object. Some examples are passing new information to be stored within that object, getting that information back and returning it or modifying the existing data in the object. All those methods are bound to the class that they are created in so only objects of that class can use those methods in order to perform the action. Object oriented programming is designed so that the methods can be reused by many other people if they are creating objects using the class you created and also is designed so that the information inside the object is not accessible unless methods are created to pull the information out as the user should only be able to manipulate the information using the methods only and not directly modifying the object. Well that's about the end of my summary on object oriented programming, plenty more SLOGs to come about what else we do in CSC148!