Object-oriented programming

**Object-oriented programming** (**OOP**) is a way of writing computer programs using "objects" to stand for data and methods. Often, computer programs that are not object-oriented are a list of instructions for the computer, telling it to do certain things in a certain way. This is called procedural programming. However, in object-oriented programming, computer programs use objects that talk to one another to change the data in those objects and to work in a way that the user wants. Because of the way object-oriented programming is designed, it helps the developer by allowing for code to be easily reused by other parts of the program or even by other people.

Most programming languages are a mix of different ways of writing computer programs (called programming paradigms). For example, Python allows for computer programs to be written both in object-oriented programming and in procedural programming. There are many programming languages that allow you to write computer programs in object-oriented programming. Some of these programming languages are:  C++, Java, Ruby, Perl, PHP, Python, C#, etc.

## Features

The main idea of object-oriented programming is that everything is an object. However, the object can be of different types:
- Variables can hold different types of information that are supported by the programming language. Examples are the integer data type and the lists data structure. Variables also exist in procedural programming languages. In object-oriented programming, variables are mainly known as attributes, particularly when it belongs (or is contained in) an object.
- Procedures are lists of instructions telling the computer to take input, do some calculations or change data, and return the output to the user. Procedures also exist in procedural programming languages. In object-oriented programming, procedures are mainly known as methods.
- Classes are collections of different variables and procedures. Classes usually talk to one another to make changes to data in order to work in a way that the user wants.
- Mixin (or mix-in) is a class that can contain a mix of attributes (variables) and methods (procedures) from other different classes or objects.

Objects is a term used to refer to instances of classes.

## Examples

In the examples below, we create a class called `Human`. This class contains the attributes `name` (for the name of the person) and `friend` (for the name of the friend). Each of the methods in the `Human` class contains a list of instructions that makes use of both the `name` and `friend` attributes.

### Python

This code is in Python.

### Java

This code is in Java.

- The Human class

- A method for talking to the Human class above

## Criticism

Even though object-oriented programming is popular, some people think that it is bad and criticize it.
- Luca Cardelli wrote a paper titled 'Bad Engineering Properties of Object-Oriented Languages'.
- Richard Stallman wrote in 1995, "Adding OOP to Emacs is not clearly an improvement; I used OOP when working on the Lisp Machine window systems, and I disagree with the usual view that it is a superior way to program."
- A study by Potok et al. tells us that there is very little difference in productivity between OOP and procedural approaches.
- Christopher J. Date said that comparing OOP to other things, especially how OOP and the other things are related, is difficult because people don't agree on the meaning of OOP.
- Alexander Stepanov suggested that OOP gives a point of view that is limited as far as math, and called it, "almost as much of a hoax as Artificial Intelligence"
- Paul Graham has suggested that the purpose of OOP is to act as a herding mechanism which keeps average programmers in average organizations from "doing too much damage". This also slows down faster, better programmers who know how to do things in a more powerful and more compact way. http://www.paulgraham.com/noop.html