From what I have learned so far, object orientated programming is focused around the creation of 'objects' and the manipulation of these 'objects'. When creating objects, programmers try to focus on combining a useful way to store their desired data while at the same time ensuring that when needed, that data can be easily accessed. Objects also serve as representations, they can represent a certain type of data and as such, valid operations can be used on objects so long as the programmer who created the object intends it to be used in that way. I feel that by giving the programmer the ability to create objects is an immensely strong tool that computer scientists have. This allows the programmer to create abstract representations of things that he would have otherwise had to use built-ins to represent. An example of this could be a simple point on the x-y plane. Now think for a moment, how could you represent a point without creating a point object? Maybe a list of 2 elements? A tuple perhaps? Neither of those have build in functions that can calculate the distance between two points or any other operation that may be useful to use on points. No matter how you look at things a point object in this case would definitely be easier to use.
Now.. recursion..
The idea of recursion was hard for me to get used to at first. Using a function itself in its own body? That made as much sense to me as the end of this sentence banana chicken pie. However, as I got used to the idea of recursion, I've discovered that it opens up a whole new window and maybe even a door or two. After realizing the power that recursion had to offer I decided to embrace the idea. With recursion, working with naturally recursive objects became a lot easier, nested lists is a prime example of this. After working with recursion I feel that I've picked up a bad habit, that is I try to see any problem as a recursive problem even if it isn't.
No comments:
Post a Comment