Anyways.
The implications of OOP for recursion
I am going to revisit my blog post on object oriented programming. I still think my bare-bones summary of object-oriented programming stands - it was correct, if a bit brief. However, what I didn't go into in that summary was the implications of using object-oriented programming.
It is really, REALLY convenient to get to treat a function as an object (specifically, as the object that the function returns). Specifically, this is convenient when it comes to recursion. This is something that really hit home when I was trying to write the grow() method for class GameStateNode (this being a recursive function that alters self directly and returns NoneType). Not being able to treat the method as an object really threw me and I can only imagine how much weirder it must be in non-object-oriented languages. I ended up figuring out a way to do it that works, but I'm not sure if that's the "proper" way to do it - afterwards, I was discussing it with a classmate and that classmate said I should have just made recursive a helper and had the helper return an object. At this point, however, I had already spent hours getting my code to work and I wasn't about to steal this classmate's idea, so I just left my code as it is. That classmate's idea takes fuller advantage of the object-oriented structure of Python than mine does, which is probably good. My function, on the contrary, is something that I think theoretically would require less changes to rewrite in a non-object-oriented language (in some hypothetical world where I know other languages than Python, of course).
Understanding the bare-bones components of object-oriented programming (objects, types, classes, instance variables, global variables, methods versus module-level functions, et cetera) was interesting and certainly informed my ability to complete the assignments and succeed on the tests this semester. On the other hand, it is thinking about the implications of object-oriented programming that actually makes me curious to the extent that I want to learn more languages. I mean, I only took 108 and 148 because of their being requirements for my Cognitive Science major, but now I must say the thought of taking 207 just for the fun of learning another language has certainly occurred to me on more than one occasion.




