Analogy between real world objects and software objects

In this article I will discuss some fundamental characteristics of an object and then compare the real world and software objects through an analogy.

Let's first discuss the technical characteristics of a real world object, a Human being.

Technical characteristics of a Human Being (Real World object)

The class "Human" defines the structure and behaviour of an object that can be called as a Human.

The moment a baby is born, an object of class "Human" is instantiated and the following are the properties of that baby.

  • The baby has a physical structure.
  • The baby occupies a certain space in the world.
  • There are certain values which are stored in the structure, which defines the state of the baby at a particular instance.
  • The baby has a unique identifier.
  • The baby exhibits the structure and behaviour defined by the class.
  • From the time of birth, if any object wants to interact with the baby, the prerequisite is that it (calling entity) should know the physical address of the baby as to where it is located.
  • Once the physical address is known, the calling entity can safely interact with the baby.

All the above mentioned characteristics of the baby are also true for a software object belonging to a particular class.

Now let's talk about the technical characteristics of a Software Object.

The following describes the technical characteristics of a software object.

  • The object has a physical structure.
  • The moment the object is created, instead of occupying a space in the world, it occupies a space in the memory.
  • The amount of memory allocated depends on the data structure and the data types used.
  • The state of the object at a particular instance is defined by certain values which are stored in the structure.
  • Every object has a unique identifier.
  • The object exhibits the structure and behaviour defined by the class.
  • From the point of instantiation, if anyone would like to interact with the object, the prerequisite is the calling entity should know the address of the memory location allocated to the object.
  • Once the address is known, the calling entity can safely interact with the object.

The above analogy shows one to one similarities between a real world and a software object. The most significant difference being, in the real world we deal with physical locations while in software we deal with memory locations.

Whatever is true for the human baby, the same is true with the software object as well.

The moment you say that an object of a class is instantiated, what happens? Like a baby, every object has a physical structure. Instead of occupying a physical space in the world, the object will occupy a space in the memory.

And how much memory will this object occupy?

Depending upon the Data type and Data structures that you have used within the corresponding class. That much amount of memory will be allocated to the corresponding object.

Because every object has a physical structure and because it is occupying certain memory locations, there are some values which are stored in that structure. And that is nothing but the state of the object at that point of time.

Every object will have a unique identifier. Needless to say, the object will exhibit the structure and behaviour defined by the corresponding class.

And finally, from the point of instantiation, if anyone would want to interact with that object, the pre-requisite is that you should reach the memory location where the object is located. If you can reach the location where the object is located, you can interact with the object and get your work done.

The reason I gave you this analogy is for people to understand the difference between the real world and software systems which is object oriented. The only significant difference is that in one case you deal with physical locations and in the other case you deal with memory locations. Most of the other things are the same.

 
Hemant Jha
Founder - VPlanSolutions
Researcher, Trainer

www.VPlanSolutions.co.in