Object-Oriented Programming is just another concept!

Understanding OOP faster

Umair Feroze
Jul 20, 2020 · 4 min read
Photo by La-Rel Easter on Unsplash

Object-Oriented Programming can be a nightmare to learn for many beginners! OOP with C++ is a wonderful head start and hopefully, it is the most interesting and simplest approach to learning OOP!

Object-Oriented Programming

In simple terms, OOP is a method of programming where you consider programs to be written based on real-world objects. Some of the common examples you would have come across would be Bank Accounts, Humans, Vehicles, and so on.

The difference between OOP and the usual procedural/functional programming that you have been learning all these days is that OOP is inclusive of everything in procedural programming but, OOP consists of classes and objects.

Class

A class is like a set! It’s a blueprint or template that can be used to create objects. Its the mold to your star-shaped cookies! A class consists of attributes and methods. It’s simple!

Attributes

Attributes are similar to variables that you have learned in functional programming, except that attributes exclusively define the physical aspects of the class, and variables can be anything.

Methods

A method is similar to functions that you have learned in functional programming, except that they exclusively define the functionalities of the class.

Concepts

The four main concepts of OOP are abstraction, encapsulation, polymorphisms, and inheritance, which makes it uniquely outstand other programming paradigms.

Abstraction

Photo by Markus Spiske on Unsplash

Abstraction is the prioritizing of important details. This concept brings about a certain level of protection, where the user will be exposed to only what the user should know, and the additional details are hidden. This is usually achieved by implementing an Interface!

This feature is commonly used in our day-to-day activities:
Suppose when driving a car, you would only interact with the interface (ie. steering wheel, accelerator, and brakes) and not pay attention to how the engine is functioning. It is unnecessary detail to just drive your car.

Encapsulation

Photo by John Bakator on Unsplash

Encapsulation is the term used to protect data. As we can see now, we are adding the necessary data within a “capsule” so that it cannot be accessed by anyone else.

Polymorphism

Photo by Dose Juice on Unsplash

Polymorphism means “many forms”, as many of you would have heard it. But what does it exactly mean? Polymorphism is the use of functions that produces output based on the input. Taking a real-world example:

Making sound to communicate is a common functionality amongst animals, however, when considering different animals, they make different sounds. Humans speak Duck quacks, Cow moos, Pig grunts, and so on.

If we give our minds the thought, we can come to a clear understanding that they all do the same thing, but based on different inputs, the outputs are different.

Inheritance

Photo by Szilvia Basso on Unsplash

Inheritance is simply a child class being able to inherit the attributes of the parent class. However, the child class may have additional attributes and functionalities over the parent class. A good example to simply understand this concept would be our parents and us:

Our parents have had certain attributes that we have inherited. This could be the color of our hair or eyes, maybe certain skills. But in addition to that, we would also have some characteristics of our own. Maybe we are faster runners than our parents? Or maybe we have a better immunity system than they do!

Conclusion

I have been through the hassles of understanding the concepts of OOP. This was maybe driven by misguidance and my excitement to learning something new.

All thanks to my friend who hinted me a more effortless way to perceive this knowledge and concepts, and bring a common and practical understanding. If you are having a hard time understanding OOP, I hope this article helps you.

The Faculty

Stories about life in academia

Sign up for The Lounge

By The Faculty

A weekly digest of what is happening in Education, Science, and Academia around the globe. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Umair Feroze

Written by

ECU Alumni👨🏼‍🎓| Software Engineer 👨🏼‍💻 MERN Developer | Innovative Tech Lover💡| Muslim ❤️ |Email: umayir10@gmail.com

The Faculty

A community of academics and storytellers writing and sharing thoughts about teaching, learning, research, and life at the faculty.

Umair Feroze

Written by

ECU Alumni👨🏼‍🎓| Software Engineer 👨🏼‍💻 MERN Developer | Innovative Tech Lover💡| Muslim ❤️ |Email: umayir10@gmail.com

The Faculty

A community of academics and storytellers writing and sharing thoughts about teaching, learning, research, and life at the faculty.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store