Friday, 25 October 2013

OOP and Recursion!

Object oriented programming (OOP) is a type of programming language model where everything is grouped into self sustainable "objects". An object is basically a "thing" that can perform a set of related activities. In OOP, objects are usually instances of classes which can interact with one another to design and create computer programs. (In python, everything is an object!) Also, in OOP, data tends to carry with it a set of functions, unlike procedural programming, in which data tends to be decoupled from the functions that operates on it. It is especially useful when there are several programmers contributing code, or when you want to reuse code between projects.

Recursion is when you take the original problem and divide it into smaller (more easily solved) instances of itself, solve those smaller instances (usually by using the same algorithm again) and then reassemble them into the final solution. Essentially, a recursion is a function that calls itself! Recursion is useful when you have data that is not always the same format or has multiple nuances, such as when you need to do iterative branching.



No comments:

Post a Comment