Tuesday, October 15, 2013

OOP and Recursion

So, I haven’t had a lot of time to update this blog lately, mostly due to midterms and various assignments. Anyway, these entries are a little late because of that sorry.

Object-oriented programming is probably one of the most intuitive things ever. It’s literally the representation of a thing (whatever that thing may be) in code.  What defines it are it’s parameters and its methods. The parameters are unique characteristics, like colour, size and shape. Methods are the things the object can do, like bounce, run and change colour. One important bit to not get confused is that the difference between a class and an object. A class is the blueprint for an object, an object is one unique variation of the class. Now, the reason I say OOP is intuitive is that -for the most part- it’s how we as human beings tend to organize the things we interact with. We categorise them by the things they have and the things they can do, hence why OOP tends to be pretty easy to understand.7

Recursion on the other hand is not quite as intuitive, at least to me. When people explained recursion to me it made a general sort of sense I could see. I mean why wouldn’t you break down a large problem into smaller easier parts that you can solve the same way you did the bigger part, right? Unfortunately, I discovered that I don’t quite solve problems that way, or rather I don’t do it consciously. When I go to solve a recursive problem I break it down through trial and error for the most part. Rarely  do I sit down and actually think through the solution enough that I would be able to fully understand it consciously, in all of its nitty-gritty detail, which is kind of essential if you want to write a recursive function. Now I’m not saying it’s not useful, of course it is, there’s tons of problems that can be simplified through recursion and the such. Never the less, I still don’t find it as useful and generally applicable as Object-oriented programming.

As a side note, I found the list-comprehensions we learned recently incredibly frustrating because seemed to make a difficult subject all the more difficult for me. True, their incredibly easy to read, which is not something you can say for a lot of code. However, they are also practically impossible to debug once written. The one line of code you use to write the comprehension leaves pretty much no room for internal debugging with which to see what’s going right and what’s going wrong.

Anyway, that’s just my opinion at the moment and who knows maybe by the end of the semester I’ll figure recursion and list-comprehensions out and love them. Anyway, I gotta go now, bye~

No comments:

Post a Comment