Friday, January 31, 2014

Week 4 - Recursion and Unit Testing

       This week we tackled a different programming technique called recursion, and a structured method of code testing called Unittest.

       Recursion is not new to me, I've done it plenty of times in high school through means of contests and clubs. Although I've done it before, I can easily say I am no expert in the area seeing that I was rather confused with regards to tracing Prof Heaps one line code. It's not that his code is too compact, it's more so our methods of tracing recursion slightly differ. He detests the stack based model in which I grew up on, thus forcing me to change my ways. Although I'd say I have fully converted to his ways, I still find it a challenge to think of recursion starting from very simple cases and growing more and more complicated with each step. This building block method is excellent, I can see how it trains you to more easily grasp the concept, It's just difficult having been used to a prior method. None the less the Wednesday lecture with the Turtle animations were really cool and fully engage you with understanding recursion through a pictorial representation.

       Unittest was something we were introduced to in CSC108 but I never bothered to actually learn it because I did not have intentions of furthering Python. This being the case, creating my own personalized test cases in lab this week were rather difficult because I had no idea of what to do. My TA refused to help me figure out how to make my test cases work, but I never refuse knowledge when it comes to programming so I ended up figuring it out on my own and getting everything to work perfectly in the end with both my understanding and my code. I can now see the beauty in Unittest although the applications we build in CSC148 are rather trivial so it feels like I'm going over board at the moment.

      All in all this week has been great because I was able to somewhat learn new things which is a nice change from CSC108.

Tuesday, January 21, 2014

Week 3 - Object Oriented Programming

                   This week in CSC148 we tackled a new programming paradigm called OOP, short for Object-Oriented programming. This programming model introduces many new topics such as inheritance, various levels of abstraction, and improved ways of handling errors. Take for instance running out of space in a stack, with procedural programming we would return -1 to notify the user of popping from an empty stack, but with OOP comes a technique called exception handling in which we can halt a program and relay more specific information to the user about the error they committed. This is one of the many important aspects of OOP which will prove its usefulness in large scale code.

                   Re-usability is a key component to the three central characteristics of a programmer, specifically being laziness. In order to fully captivate this core characteristic, we must first learn of shortening code which we've already seen through the use of functions and procedures. With OOP the whole point is to create a blueprint for which we can build more specific objects based off of it. If we want to create a volvo volkswagon and a dodge caravan, both these objects are called vehicles from which we derive their specific attributes belonging to each. Instead of having to redefine the engine, steering wheel and other attributes among all vehicles, we can inherit these general characteristics, and tweak them however we please! Who would want an engine in a volkswagon that's also in a dodge caravan? That would make for awfully terrible gas mileage as well as horsepower loss.

                   This is just the tip of the iceberg in Object-Oriented programming design, I'm sure more will be understood later on in the course, for which I am looking forward too.