object Oriented Principles in Real Life

OOP

Your 4 years of engineering must have introduced you to the object Oriented Principles for
sure. And if you have already started working in a software development line, be it any
technology, you must have found yourself implementing these principles in your code.
The OOP concept holds great importance in software development and so does in our real
life. We all implement them in some or other situation.

Initially, I started understanding the concepts from interview point of view, seldom did I felt that I need to understand them at the core. But from the past 1 year, as I became quite old in the tech industry, 6 years to be precise, it is expected to know the concepts like the back of your hand. And so with the help of my tech-buddies I started taking more interest and understanding them at the depth. I watched several videos of OOPS, SOLID Principles by Bob Martin, and many online articles explaining the same. I even bugged many of tech-buddies to share their knowledge with me whenever time permitted.
Well, though I have understood the concepts, I’m not here to explain them in technical
situation. Being a creative writer I discerned their benefit in real life.
Disclaimer: I don’t intend to hurt the feelings of any techie out there about the OOP concepts,
the content is for mere tickling the brain. So let’s start with it.
I would assert more on the below 4 concepts in this article

  • Encapsulation
  • Abstraction
  • Polymorphism
  • Inheritance

Encapsulation aka Information Hiding.
Ok, this example is a bit emotional one but I don’t intend to make you shed tears.
Situation: Lower class Parents of a school going kid in the 90’s. The father has a tough time
earning his livelihood. He needs to pay the term fee of his kid, buy him books, bags and
other school stationaries plus also look after the house expenses. And he does meet the
needs in due time. He has the money for it, but the pain, hard work he puts in, the kind of job
he does not bothering if it matches his graduation degree or not, is the information that he is
hiding from his family. As per him the family needs his love and money to support a living,
that is the requirement he fulfills and hides the information which he considers to be of not
much importance to be revealed.So Encapsulation. Sounds right?

Abstraction aka Implementation hiding.
We make a plan but we hide the execution details. So let me explain this to you with an
example.
we plan for a movie, may be a xyz movie with a abc friend. The abc friend can be a
male/female which will be decided at run time. The movie might be followed by lunch, then
desert, then some time spent in a park or a walk along the beach.
So to initialise the movie plan we need cash as an input for the constructor.
So we tell our parent that we need a x amount as input for the movie plan, but we hide the
information : movie name, theater, who will accompany us and what happens after the movie
gets over etc etc. We just need to convince the parent for the input. And abiding by the
abstraction principle, they aren’t liable to know what happens inside. Agree?

Polymorphism
Polymorphism is a Greek word that means “many-shaped”, meaning it behaves differently
depending on the situation.
we have a function: RideBike
but the functionality will differ depending on who is sitting on your bike.
we can have 3 implementations of it depending on the input parameter which will be as
below
Mum/dad
friend
Girlfriend
So if it is mum/dad: the speed will vary, will be considerably low. We will avoid sightseeing
on the road.
If it our friend: we might ride rough, totally unconcerned if our friend is scared to death or
whatever, we will take any routes we want to. we will do more than required sightseeing,
singing LP songs on high pitch might be involved depending on the time or place.
If it your girlfriend or a person you just started dating : the speed will vary of course, there will
be sudden jerks irrespective we come across speed breakers or not.The routes will vary, we
will pick routes where we have less chances to be seen by familiar faces.
So does that sum up enough of Polymorphism? I hope yes.

Inheritance
Well as the word says in itself
Inherit, the good, the bad, the belongings.
The wealthy kid will inherits his family’s wealth, so lucky that soul will be, I envy.
The youngest kid in a middle class family will inherit the school textbooks, notes, and even
uniform from his elder siblings if it fits him.
Phew. I believe that is enough of a tickling for your brain and stomach as well.
If you like the article and wish to read more of different kinds that I write, do subscribe to my blog.
Till then Happy reading, cheers!!


 

4 thoughts on “object Oriented Principles in Real Life

  1. I guess no one thought of it earlier… I would definitely recommend this article for upcoming Oops learners :-)

Leave a Reply

Your email address will not be published. Required fields are marked *