Monday, 14 October 2013

Object-Oriented Programming and Recursion

Object-Oriented Programming and Recursion

Object-Oriented Programming

Object-oriented programming (OOP) languages focus on creating objects (or classes) that contain data. Each object has methods associated with it that perform tasks specific to the data structure being used. Before the advent of OOP, programming languages focused on allowing the user to write procedures that operated on data. OOP is useful because specific data structures often have very specific ways in which data can be operated upon, and the methods defined for any object will reflect this. Methods that are apprpriate across multiple classes can be inherited to save a programmer from code duplication. OOP also allows programs to correspond more closely to objects in the real world. It seems that object-oriented programming is a very useful tool for computer programmers.

Recursion

Recursion is defined as defining something in terms of itself. In programming, recursion is referred to as a function that calls itself inside of itself. It is often used to analyze data that is organized recursively, such as data structures that have miniature versions of the same data structure contained within. For many problems in programming, recursion is the easiest and sometimes the only way to solve them. Otherwise, one would have to access each substructure in a new way. Recursive programs must also include some kind of exit condition, or the result may be an infinitely looping function call. Recursive programming mimics many structures in nature, such as trees, where each branch can be conceived of as a smaller tree.

1 comment:

  1. Good descriptions! It would be neat to see samples of what you coded.

    ReplyDelete