Monday, October 14, 2013

On recursion

Object oriented programming and recursion go hand in hand. But not only because of the way recursive methods can be written. I contend that to use OOP is to be recursive. That is to say the solution to problems in OOP is recursive.
Take for example the equivalent of constructing a building object using programming.
To build an entire structure without any plans would of course be an insurmountable task, but if we break the problem into smaller pieces the solution will reveal itself.
We begin by stating that we want to create a building object.
In order to build a building we need bricks,cement and workers.
Now we instead solve the simpler problems of creating a brick object, a cement object and a worker object ( they are by definition simpler than the building object since the building object will utilize all of their complexity as well as its own )
This idea can be scaled to greater and smaller degrees, but the point remains: Recursion is the spirit of solving big problems by applying the same solution to smaller problems.
OOP programming solves the big problem of complex systems by implementing a bunch of simpler systems first ( objects!)

No comments:

Post a Comment