Tuesday, April 1, 2014

For my High Schooler - Object oriented vs Procedural Languages


Yash: Do you know, today we discussed difference between Object Oriented and Procedural languages.

Me: That’s good. May you like to explain to me?

Yash: Yes. It is very simple.

Yash: Before that I have a story to say.

Me: Go ahead.

Yash: OK.  I have a question for you.

Me: As you wish.

Yash: On Saturday morning mom ask you to go and get a bread loaf from grocery store.  What are the different things you will do?

Me: It is easy. I will get dressed. Fetch the car from garage and drive to store. Park the car in parking lot. Enter into grocery store, fetch the bread loaf. Pay for the loaf. Ride back to home in my car and that’s all.

Yash: OK.  In your answer, you are focused on verbs – sequence of actions.

Yash: I can explain the same story in different way where focus will be nouns. There are various entities like Mom, Dad, Car, Parking Lot, Store, Bread Loaf, Cashier, etc. These entities has their own actions like Car can move from Home to store and back, Cahier can accept the money etc. Interaction of these entities will result in purchase of bread loaf.

Me: accepted.

Yash: Moreover, an entity may perform several actions, say cashier can accept money and also give carry bag. This mean if we explain in terms of noun, system can grow in complexity and scale.

Me: I am overwhelmed.

Yash: In languages where focus is verbs are procedural languages. In Object oriented languages focus is Noun.

Me: Great!

No comments:

Post a Comment