If you are a student or a graduated of Computer Science, you may have or may have had a course called “Object Oriented Programming (OOP)” or “Advanced Programming”. If you’d like to describe what OOP is, what will you say? I personally use this example in my classes:
Assume that today our GOD wants to create a new human. Will He redefine the concept of all properties and operations of human? Will He frequently redefine the concept of, for example, “eye”, “ear”, “heart” and so forth? Will He redefine the concept of “Crying”, “Seeing”, “Walking”, etc?
Definitely if He did so, He would waste a lot of time, and according to our beliefs, negative adjectives like “Time Wasting” does not have any way to our GOD.
It seems that GOD has a template or model which all of these body parts and their functions have been defined in. This template is flexible like kids Play Dough so GOD can make changes He prefers while he is creating a new human. (For example He can make the eyes and ears smaller or larger, etc.)
When GOD wants to create a new human, there is no need to redefine the concepts of eyes or ears or the way they act…
The only thing He has to do is to choose some values like the color of eyes or the size of ears and put all of them (plus the Adam’s essence) in that template and the new human is ready!
OK, now in Object Oriented Programming we say:
Assume that a programmer is designing a program for a University. (University Management System). Will he define all properties and operations of each student separately and repeatedly? For example will he frequently define the concept of “First Name”, “Last Name”, “Father’s Name” and so forth? Will he say, “OK, “First Name” is string, its max-length is 50 characters, “Birth date” is DATE, its format is YYYY-MM-DD”, etc? Will he define the concept of “Add Student” and “Edit Student” for each student and in each part of the program separately?
Defiantly if he does so, he will waste a lot of time, but a good programmer does not waste the time!
It is better to create a Template and define all students’ properties and operations in it. This template should be flexible so that the programmer can change some parts while he is creating a new student. (For example in the previous example, GOD should be able to change the operation of eyes to create some blind or poor eyesight people, and now the programmer should be able to change some functions of “Add Student” for the students of different levels)
When the programmer wants to create a new student, there is no need to redefine the concept of “First Name”, “Last Name”, “Birth date” and “Add Student”, “Edit Student”, etc. The only thing he needs to do is to get some values for the properties (like “Hamid Reza” for “First Name” and “Niroomand” for “Last Name”, etc) and put all of them in the template and the new student is ready!
In OOP, that Template is called a CLASS. Those body parts like eyes and ears are called Property Names. Their values like “blue” or “big” are called Property Values. Their operations and functions are called Method and the flexibility of a class is called Overriding.
Anyway, I hope you have gotten the concept of Object Oriented Programming, otherwise you may need to review your OOP textbook :).
My aim in this post was to tell a story.
Every time that I say these concepts to my students in OOP classes, I wonder, “Does GOD really has a Class and Template for human?”
At our local mosque, people read a page of Quran every night. Two nights ago, when the reciter was reading the first Aya of Nesaa Sura, I became really surprised! My eyes were like this
Have a look at this Aya:
O mankind! Reverence your Guardian-Lord, who created you from one living entity
In English Translation نَّفْسٍ وَاحِدَةٍ has been translated as “One living entity” or “Single Soul” or “One being” but now, we programmers know that GOD is speaking to us! He means “I’ve used Object Oriented Programming in creating humans!”
Yes, GOD is an Excellent Programmer! 🙂
Wish you success.
Hamid Reza Niroomand
This is an English version of this post:
تشریح مبحث شیئ گرایی در برنامه نویسی با استفاده از قرآن