The first step to Object thinking would be to think about the objects. From the beginning the key aim in developing a programming language is to make it as humane as possible. And as each programming language was developed, we came closer and closer until we realized that we are missing out a big picture to imitate our lifestyle of interacting with objects. Just think about a moment in your day. Try counting the number of objects you interacted in that moment. OOP is all about creating programs with objects that interact with each other like the way we interact with objects and objects with each other. Let us take a simple example of preparing a coffee. For any problem we have to limit the scope, so here we assume we have the necesary things and environment to prepare coffee.
Step 1: Take a vessel and fill it with a cup of milk
Step 2: Light on a match stick
Step 3: Switch on the gas stove and light it using the fire from step 2
Step 4: Keep the vessel on stove
Step 5: When the milk in the vessel starts to boil switch off the gas stove.
Step 6: Put a spoon of sugar in a cup
Step 7: Put a spoon of coffee powder in the cup
Step 8: Add the boiled milk to the cup
Step 9: Stir the mixture in the cup well with the spoon.
Ofcourse the preparation method and type of coffee could vary depending on the taste and type you are used to. You could also elaborate and keep abstracting the above steps (for example before step 6 you could say take the sugar jar and take a spoon full and so on), but be practical and if you keep abstracting you will lose focus on the problem. The idea here is to think about the objects involved in the above steps and identify its purpose. So lets list a few.
Vessel - a container to hold anything in limited quantity, used to cook
Cup - a container to hold anything in limited quantity, used basicaly to temporarily store and transfer
Match stick - stick that can be ignited to bring a flame.
Ok you could argue with me on the purpose descriptions above, but you are right whatever you describe as the purpose as far as you are clear with what you know as the purpose of that object. Now if you see in the above steps you can also see that there is a chain of reaction that happens between the objects with the outcome, you holding a cup of coffee. So it is not just objects but the interaction between objects and you and objects that’s making this world go around. But more than just understanding object interaction, a critical point is the purpose of the object is well defined and does not work beyond its purpose. For example you cannot bring the gas stove to flame with a vessel or a cup. The second important point is you have to use the objects in the right way specific to the problem you are addressing to make use of it effectively. For example if you try to keep the vessel upside down over the gas stove, the vessel doesn’t care but it does not solve your problem.
The next step to the above exercise is that you can think about object interactions and the sequence. This is one simple exercise that you could keep working on as many times in a day. Try thinking about the sequence of steps and the objects involved and their interaction next time when you sit before your TV and switch to another channel using the remote. You dont need to write it down or sit before your computer to do it, your mind is the notepad and brain is the processor, use them effectively and you are the master.
Fatal error: Call to undefined function wp_sociable() in /home/techmasa/public_html/wp-content/themes/techmasala/single.php on line 21