DEV Community

Zaynaib (Ola) Giwa
Zaynaib (Ola) Giwa

Posted on

What is Object-Oriented Programming

What Is Object-Oriented Programming?

Object-Oriented Programming(OOP) is a programming paradigm to organize code on the concepts of objects. An Object is when you bundle data properties and behaviors(functions/methods) together.

Why use OOP?
OOP allows you to create large-scale applications with modules that are independent of one another.

Key terms

Classes and Instances

A Class is a blueprint for objects.

An object is an instance of a class.

Key Concepts to OOP

APIE - Abstraction, polymorphism, Inheritance, encapsulation

Abstraction - Is the overall essence of an object. What qualities/features trigger the overall association of the object.

For example when I say the word dog. You automatically know what I'm talking about.

I did not have to name a specific example of dog i.e. Golden Retriever to make you understand that I'm just talking about dogs in general.

Encapsulation - Is when you hide or restrict access to data in your program. Many people use the term black boxing. A user is only focused on the input and output of a machine and is not concerned with how the machine works.

We use black boxing every day of our lives. For example, when you drive your car. Do you need to know how your engine works in order to drive a car? No. All you need to know is that you need gas and you stick the key in the ignition in order to make the car move forward.

Inheritance - Is when a class receives attributes and functions from another class. It's similar to us humans. You inherited characteristics from your parents but you are not a total clone of your mother or father.

To test that two classes have inheritance relationship use the IS-A test.

Let's say we have a parent class(superclass) called Toy Dogs. A chihuahua IS-A toy dog. A Pug IS-A toy dog. A Great Dane IS-NOT a toy dog.

Toy Dog Chart
Image Source

A concept similar to inheritance is composition. Composition is when two or more objects make another object. The relationship is one of ownership. Use the test HAS-A to check if its a composition.

A car HAS-A engine.
A Jedi HAS-A lightsaber.
A pokemon trainer HAS-A Pokeball.

Polymorphism - is the ability to take several forms. In oop we use overriding and overloading to achieve this.

Overriding is when a subclass changes the functionality of a method with the same name.

Overloading is when a class has multiple methods of the same name.

Other OO* terms

|OOA | Object-Oriented Analysis | Understanding your problem
|OOD | Object-Oriented Design | Create/ Design your solution to the problem
|OOP | Object-Oriented Programming | Programming your solution

Further Reading and Resources

Object-Oriented Programming for Python by Dusty Phillips
UML Distilled by Martin Fowler
Head First Object-Oriented Programming and Analysis
How to learn Software Development and Architecture - a Roadmap
FreeCode Camp 2019 Web Developer Roadmap
What is object-Oriented Programming-Real Python

Oldest comments (2)

Collapse
 
akoruji profile image
Akor Augustine Uji

Hi Zaynaib. Nice article. Next time, remember to give copyright to digital content like images (case in point is family tree of dogs) . I'm afraid copyright infringement is a big deal this days.

Collapse
 
zaynaib profile image
Zaynaib (Ola) Giwa

Thank you for the tip! :thumbs-up: