Sunday, 20 October 2013

Object-Oriented Programming and Recursion

Object Oriented Programming is a way of structuring code to create "objects" that groups relevant variables and functions (methods) together. It really helps when someone is writing a larger or more complex program but even smaller programs can benefit from OOP. It helps to organise and clarify for others reading the code as well as the programmer. The ability to create your own objects means that you are not restricted to built in data types and objects. A programmer can create an object that is tailored perfectly to the program's needs.

Recursion is when a method or function calls itself. In order to stop infinite recursion, there is one or more base cases. Once one of these cases is met, return values are then sent back up the recursion chain until the original call to the function is reached. Recursion, although less straight forward than loops, is extremely helpful to programmer, often shrinking a long series of loops and if statements to just a few lines of code. Some problems are very difficult to solve without recursion, making it a very important tool for programmers to possess.

1 comment:

  1. Surprisingly, but object-oriented approach was inspired by early designs of computer virtual memory. You should look forward to 369 to find out that!

    ReplyDelete