Classes and Objects – Encapsulation
Previously we have covered the following that every thing on this earth has Physical Properties and Utilization or DATA and FUNCTIONS. In this post we will get more technical and shall be covering concept of Classes and Objects and ENCAPSULATION.
Don’t get to worried about all this technical jargon, we will try to keep it simple; so that we can keep our flight as smooth as we can.
We know that in terms of things we categorized them as Living things & Non-Living things. Among living things we have mammals, amphibians, fish etc. not to forget we have plants as well!!
So if we know the DNA structure of a single species we can create multiple species of the same kind. Remember Jurassic Park!!! Do not consider that I am a movie maniac, just there happened to be lot of good movies on the subject.
Precisely on the same level; if we have a DNA structure for chair (if it were) we can create lots of chairs with the same qualities.
This is the difference between CLASS and OBJECT.
Class is the DNA structure or a blue print to create multiple species of the same Nature that we call Object.
Simple Isn’t it.
So we fly higher, that if we combine DATA & FUNCTIONS in form of a class we have achieved ENCAPSULATION.
So pretty well you can consider that when the machines understood the blue print of each and every thing on this earth, they just had to create multiple objects of each blue print to create a virtual world. Ask your self then… is MATRIX possible?
Take every example on this earth that you can find; each thing will belong to a Category which is the CLASS for it and each instance of that category will OBJECT.
Look at the Star and Solar Systems; Each PLANET belongs to a PLANET class and each PLANET itself is an object of that class.
Now you must be asking that all the planets are not the same, and yes that is precisely the idea. That object will have some different data like each planet has different size, mass and environment. But always remember that we are talking about different VALUES of data, not the data it self.
Like each planet has SIZE, MASS, they are generally OVAL.
On the same pattern if you consider HUMAN BEINGS, each of us has the same characters generally and yet our faces are different; as the VALUES of our DATA is different from each other.
So its all about classification of a thing (object) in a particular class; we put those objects together and BAM!!! We have created our world.
In the next article we will cover INHERITANCE & POLYMORPHISM and move on to the practical issues about designing an object oriented solutions.
For further reading please refer to http://it-pedia.blogspot.com