Tuesday, 15 October 2013

SLOG #1: Recursion and Object-Oriented Programming

To start off this illustrious blogging assignment (a little late, as it's now week six of the academic year), let me start by saying this is the weirdest computer science assignment I've ever been given.

This has been my first time using Python, though I come from a pretty in-depth Java background. Object-oriented programming is kind of my jam because of that prior experience, and as opposed to finding it particularly challenging, I've found it to be a comfortable and familiar place for me to work in this strange language where you don't even declare your variable types (which, by the way, was the greatest struggle to overcome during the first exercise).

Object-oriented programming revolves around the idea that your code for a class is essentially the blueprint for an object, and these objects have their own variables and fields, which "describe" the object, and methods/functions that can change, access, or perform tasks with the objects created by that same class. Again, coming from a java background, I find object-oriented programming to be a lot more organized and handy than anything else. It is a handy and useful way to be able to create objects that can interact with each other, and to do things that would otherwise be unnecessarily complicated without object-oriented code. Different objects can interact with each other, which again, is probably the preferable way of writing more complicated and user interface-centric code. For example, if you wanted to create a simple tic tac toe game, you could create a class for the grid, the x, and the o, and there would be code within those classes to create the objects, visually represent them, and then have them interact with each other.

Recursion, however, does not give me the warm and familiar feeling of being right at home. It didn't make sense when I was coding in Java, and still makes very little sense to me now. When I start on a recursive problem, initially, I start thinking, "oh, yeah, this makes sense, I can think this through no problem!"

Except then I start thinking too hard, and I confuse myself, and get frustrated, and oh god everything goes downhill from there. Ways to remedy this? I plan on spending a lot more time on a very useful website: http://codingbat.com/python

Codingbat is a coding practice website my high school computer science teacher introduced me to, which was a huge help when I was learning java. It gives practice problems for different programming ideas, and has them in python and java. The python section is a little lacking, but there are a lot of recursive problems given in java, which alone should be a huge help, as writing the code isn't really my problem, but rather, just being too inexperienced with recursive problems. (For the record, I am that one person who will try to use ridiculous long and complicated nested loops just to try to avoid recursion. It only works sometimes)


No comments:

Post a Comment