Sunday 5 October 2014

What is object-oriented programming? - By Steve Jobs

Background

If you know Java or C++ then you are already familiar with what Object oriented programming. It is a simple yet tricky concept to understand. I was browsing through some of the programming questions on Quora and came across this answer about OOP. It is as described by Steve Jobs in an interview. I am not aware of the source for this but I am still going to go ahead and put it down here as it is a very good real life scenario to illustrate what OOP is.


What is object-oriented programming? - By Steve Jobs


Here, in an excerpt from a 1994 Rolling Stone interview, Jobs explains what object-oriented programming is.


Jeff Goodell :  Would you explain, in simple terms, exactly what object-oriented software is?

Steve Jobs : Objects are like people. They’re living, breathing things that have knowledge inside them about how to do things and have memory inside them so they can remember things. And rather than interacting with them at a very low level, you interact with them at a very high level of abstraction, like we’re doing right here.
Here’s an example: If I’m your laundry object, you can give me your dirty clothes and send me a message that says, “Can you get my clothes laundered, please.” I happen to know where the best laundry place in San Francisco is. And I speak English, and I have dollars in my pockets. So I go out and hail a taxicab and tell the driver to take me to this place in San Francisco. I go get your clothes laundered, I jump back in the cab, I get back here. I give you your clean clothes and say, “Here are your clean clothes.”
You have no idea how I did that. You have no knowledge of the laundry place. Maybe you speak French, and you can’t even hail a taxi. You can’t pay for one, you don’t have dollars in your pocket. Yet I knew how to do all of that. And you didn’t have to know any of it. All that complexity was hidden inside of me, and we were able to interact at a very high level of abstraction. That’s what objects are. They encapsulate complexity, and the interfaces to that complexity are high level.



Let me relate the above in a more technical way. There are various things that define each individual - their name, gender, age, country they live in, language etc. This is the structure of "people" and the different values for each parameter define unique individuals. This is nothing but Classes which define how your Objects are in Java. The person asking for laundry and the person carrying out the task are both different Objects. What Jobs meant by saying that the person requesting for laundry is not aware of the complexities involved in carrying out the actual process is actually what is termed as data encapsulation. All that is done here is delegate task to type of Objects that understand the task. If you go a few steps ahead all - the Cab, the Laundry, the laundry man are all Objects. Laundry man Object knows where to get the laundry done but how do we get there ? He will need a Cab Object where he would say take me to  X place. Now the Cab object knows how to drive from place A to place B. So Laundry man does not have to worry about the complexities of getting to laundry place. If you see a broader picture we all in day to day life are all Objects with specific attributes and function and we continuously interact and delegate to work as a System. This System is nothing but the Java program and the ecosystem is nothing but the JVM (Java virtual machine).


Some characteristics that define a OOP design - 

1. Object              -    Instance of Class
2. Class                -    Blue print of Object
3. Encapsulation   -    Protecting our Data
4. Polymorphism  -    Different behaviors at different instances
5. Abstraction      -    Hiding our irrelevant Data
6. Inheritance       -    Object inheriting propertied from it's parent.



Related Links

t> UA-39527780-1 back to top