Thursday, 30 January 2014

Week 4 - Inheritance and Analyzing Recursion

Inheritance is the process by which data can be shared between classes or objects in such a manner that the "child" class or object inherits the methods and attributes of the "parent" class while retaining the ability to have specific methods of its own. This is especially useful in handling errors, as in exercise 2, where any custom errors can simply inherit the data of superclass exception.

So this was introduction to recursion week, a new topic for me. It did not really feel that way though, the tracing we did in lecture was fairly straight forward and seemed to be more just common sense than something that involves a great deal of thinking. That being said, it is worth noting that the recursive formula that was used in the end looked completely mystifying on first glance. I think that the lectures on nested list depth would have been better if we spent less time tracing through the lists and more time on developing the recursive formula.

All in all, a really good week. My favourite part of it was definitely the code for tree burst that we analyzed, as I found it to be simple to understand. The logic of how the code called itself was very obvious and made it easy to predict how the next stage should look like. As well as the fact that the patterns it produced looked amazing on higher values of level!

Thursday, 23 January 2014

Week 3 - Object Oriented Programming: From Words to Code


Going from a problem written in words to a solution written in code is the goal for all programmers. Object oriented programming is one way to do just this, focusing on key words, typically nouns, and turning them into "objects", custom classes featuring their own constructors and any other attributes you choose to define for them. They can interact with other objects and preform functions defined for them, usually by verbs in the original problem.

The usefulness of objects and object oriented programming is clear, simplifying problems into a series of statements which define which objects are to be created, what they should look like, what they should be able to do and how they should interact with other objects. Other than just making problems more comprehensible, I believe that the real power of object oriented programming is that it makes code more readable and closer to actual language. It's not so hard to see how,"The dog played with the toy." can become Dog.play(Toy), where dog and toy, two nouns, become objects, and play, a method. This makes it feel less like coding and more like communicating with the computer.