It’s very popular and widely covered topic but there is a reason why I chose to write on this topic
In my 15 years of IT experience I have interviewed hundreds of engineers,,senior engineers, tech leads, architects etc but I found very few people having proper knowledge of the subject.
It’s very fundamental but basic concept of programming
Most of the people even fail to visualize the difference between class and the object.
They just mug up and say that the class is like blue print and object is the instance of the class
Let’s start thinking
How would be our programing if there was only class but no facility to create objects
Let take example of car Having blueprint is like having sketch of the car but not a real car
You have to create on object of the car class then only you can have real car.
The beauty is that you can create any number of objects through that blueprint.
So there is only one blue print but you can create millions of cars of that type.
All look same type in drawing but they can have different colors
You can place 1 million cars in your parking at a time and all can have different colors
What about static class.
You can have real car but at a time only one color
In fact only one car. You have different color cars but at a time only one.
Is that not really exiting
Don’t you think you have become like God Suppose you are having person class. Wow you can create billions of persons and they can exist at a time and they can interact
What?
They can’t have billions colors
Well that is not limitation of object oriented model but the limited variety of colors possible
Now let us talk about some basic concepts of OOPs
Naming them
- Abstraction.
- Encapsulation.
- Polymorphism.
- Inheritance.
- Association.
- Aggregation.
- Composition
Abstraction and data hiding relate to the very nice concept of OOPS.
When ever you don’t want to show the inner functioning or inner components to the outside world you do abstraction.
Or if I say in more positive way then Hiding the unnecessary complexity but revealing only relevant data to the end user is called Abstraction
For example if want to drive a car just need to know how steering accelerator, break and clutch work. You don’t need to know inside mechanically they are composed.
Now you might be thinking why the hell I am treating you as car driver.
No my dear I am not, I am just trying to explain Abstraction by using real word example.
Okay let’s say you are game developer and you want develop one car racing game
What you need is a car object and a driver object.
You will develop some methods through
which you can enable the driver to drive the car.
To be continued…….