Why Class is Important and Why we Need Objects

Hi friends. I am trying to explain what a class and objects are, why we use encapsulation, abstraction, delegates and so on.

I will start to explain by relating to a real-world example.

I think you know that there is no class in the C language.

  • God invented our world and he wanted to make our planet a nice place to live.
  • So God decided to create a person named “C-language” and sent him to earth and asked him to make this place a wonderfull place.



  • “C-language” started by doing small jobs. Like calculator app and other small apps.
  • Everything was fine. After doing small jobs, he started to move to a larger task. Like manufacturing cars, bikes and electronic items. “C-language” was not able to remember all the jobs like calculating, manufacturing, forming.



  • After working for years when he was about to die (when the developer was migrating from one company to another, other new developers should take care of his projects), he found it was very difficult to teach is son all his skills.
  • God was angry. The work was too slow and the person “C-language” is encountering too many difficulties.
  • So God decided to invent a group of persons (static Classes in C# language) such that each will be specialized in their own working field. Now the earth was turning into a beautiful place.
  • A farmer was good at farming, a car manufacturer was good at making cars (here I mean each class doing their respective job).
  • Now since there are too many people on the Earth, it was difficult to them to share a single car. Unfortunately there is only a single car.
  • So God now decided to produce many cars from a car factory. So that whoever was interested in buying a car can have their own. (A class can have any number of objects. So to server for a specific class. I will create an object of that class and I will use it. So that there is no need to share my object with other classes. If another class is interested then they will end up with their own object).



  • So now you understand why classes and objects are important.

Now let's see why OOP principles, in other words why to go for abstraction and encapsulation.


Recommended Free Ebook
Similar Articles