Friday 6 December 2013

OOP & Recursion

Object-oriented Programming
Object-oriented Programming focuses on using a set of code (e.g. class) to create an "object" with corresponding functions used as "methods".  If we think about the code in terms of everyday language, objects are nouns that each have basic, preset attributes. To interact with these specific types of objects, there are methods that can be used when called upon, much like verbs. Several objects can connect and interact simultaneously because of these consistent methods and presets that each object contains. OOP is useful for organizing/creating new sets of data or built in functions that the programming language itself doesn't already possess in order to accomplish a specific task.

Recursion
I actually came across this topic for the first time in another course I took previous to 148, CSC165. In hindsight it would have been a better idea to take 148 & 165 concurrently, but the course did teach me the general idea of recursion. The way I understood it was that recursion allows code to repeat itself until it found a simple solution: essentially, recursion was magic. Recursion still feels like magic to me, but its mechanics were meshed out much better after completing assignment 1. CSC148 taught me that recursion helps unravel the problem until it is in its simplest form. If the problem can be solved with its simplest example, the repetitive nature of recursion means that the larger problem can be solved bit by bit. In terms of how to solve through code, a recursive function has a simple base case and contains a call to itself with a change in its variables. Evidently, recursion is useful when dealing with mathematical problems involving sequences or iteration. It is also efficient in the sense that it solves a large problem but requires less code.