Object-oriented programming, also called OOP, is a model for writing computer programs. Before OOP, most programs were a list of instructions that acted on memory in the computer. Instead of a procedural list of actions, OOP is modeled around objects that interact with each other. Classes generate objects and define their structure, like a blueprint. The objects interact with each other to carry out the intent of the computer program.

Many design patterns have been written utilizing OOP principles for code reuse.

A study by Potok et al.[2] 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 thing are related, is difficult because people don't agree on the meaning of OOP.[3]

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" [4][5]

Paul Graham, a successful internet salesman and programmer, 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.. [1]

classHuman(object):def__init__(self,name,friend=None):self.name=nameself.friend=frienddefsay_name(self):print("My name is "+self.name)defsay_goodnight(self):ifself.friendisNone:print("Good night nobody.")else:print("Good night "+self.friend.name)#create a new human object named stephenstephen=Human("Stephen")#create a human object named joe with stephen as a friendjoe=Human("Joe",stephen)stephen.say_name()#shows 'My name is Stephen'stephen.say_goodnight()#shows 'Good night nobody.'joe.say_name()# shows 'My name is Joe'joe.say_goodnight()#shows 'Good night Stephen'

publicclassHuman{privateStringname="unnamed";// the name of this humanprivateHumanfriend=null;// the human's friend/** * This "creates" a new Human */publicHuman(Stringname,Humanfriend){this.name=name;this.friend=friend;}publicHuman(Stringname){this.name=name;this.friend=null;}publicHuman(){this.name="unnamed";this.friend=null;}publicvoidsayName(){System.out.println("My name is "+this.name);}publicvoidsayGoodnight(){if(friend==null)System.out.println("Good night nobody.");elseSystem.out.println("Good night "+friend.name);}}

publicclassMain{publicstaticvoidmain(String[]args){//create a new human object named stephenHumanstephen=newHuman("Stephen");//create a human object named joe with stephen as a friendHumanjoe=newHuman("Joe",stephen);stephen.sayName();//shows 'My name is Stephen'stephen.sayGoodnight();//shows 'Good night nobody.'joe.sayName();// shows 'My name is Joe'joe.sayGoodnight();//shows 'Good night Stephen'}}

classHuman{private:stringname;// The name of this humanHuman*mFriend;// The human's friendpublic:// This "creates" a new HumanHuman(stringName,HumanFriend){name=Name;mFriend=&Friend;}Human(stringName){name=Name;mFriend=NULL;}Human(){name="unnamed";mFriend=NULL;}voidsayName(){cout<<"My name is "<<name<<endl;}voidsayGoodnight(){if(!mFriend)cout<<"Good night nobody"<<endl;else{cout<<"Good night "<<mFriend->name<<endl;}}};

intmain(){Humanstephen=Human("Stephen");//create a new human object named stephanHumanjoe=Human("Joe",stephen);//create a human object named joe with stephen as a friendstephen.sayName();//shows 'My name is Stephen'stephen.sayGoodnight();//shows 'Good night nobody.'joe.sayName();//shows 'My name is Joe'joe.sayGoodnight();//shows 'Good night Stephen'return0;}