Sunday, 13 October 2013

Entry 1: Recursion and OOP

Object-orientated programming:

Insofar as I understand it, the primary distinction between object-orientated programming and other 'styles'(which to my recollection we have not dealt with explicitly) is the bundling of certain data with its appropriate methods into the titular 'objects', as opposed to simply writing a number of functions to use the data as you wish, while leaving it separated it from them in a mass(I assume that the methods of the non-OOPers are not as primitive in actuality). The former method seems as if it would have many advantages over the latter. Simply on the level of organisation, knowing from the structure of the code how functions(methods) and data relate would seem to be an advantage; if a change to the program was necessary, it seems to me as if OOP-styling would make it's implementation easier and its debugging more expeditious. I am not currently equipped with the knowledge to comment on how this might effect the functioning of the program itself, but I suspect the impact is non-trivial.


Recursion:

Recursion thus far has come in two flavours: recursive data structures and the recursive functions which we have written to operate on them(the latter has been the primary focus, and our of use of recursive functions has not been limited to dealing with recursive data structures). Unless I'm missing something, the nested list has been the only real recursive data structure we've encountered, and usually only really as a motivating example for the use of recursive functions. I've found writing recursive functions to be challenging and intellectually exciting. There's a certain elegance when you finally conceive of a recursive solution to a tough problem; this sense of elegance is only magnified by the fact that you often only have to write half as much code to implement it! Again, I don't feel confident making any sort of grand pronouncement as to the usefulness of recursive functions more broadly to computer science, but they seem to be the optimal approach in certain situations, especially when dealing with the aforementioned self-similar data structures.

No comments:

Post a Comment