What is OOP?

What is Object Oriented Programming (OOP)

Object Oriented Programming is the use of self-contained pieces of code used to develop applications. These self-contained pieces of code are called Objects. We use Objects as Building Blocks when building applications.

 

Where can you use OOP?

Object-Oriented Programming can be used by many Languages such as:

  • JavaScript
  • PHP
  • Java
  • Python
  • Ruby
  • Perl
  • Objective-C

 

Inheritance

When using Object Oriented Programming, you can use many Features and Techniques, one of these is Inheritance. Inheritance refers to an object inheriting methods and/or properties from a Parent Object; usually a class or a function. Inheritance is a way to reuse once written code again and again, which can save a lot of time. Inheritance is one-sided, meaning; the child can inherit behaviors from the parent, but the parent can’t inherit behaviors from the child.

 

Polymorphism

Polymorphism is assigning a different meaning, usage or behaviour to an object so it can appear in many forms. A real-world example would be like this: You (the Object) may behave differently depending whether you are at School, at Home or out with your friends. This can work the same way in OOP, you want a particular object to work in a different way, depending on how it is used.

 

Abstractions

Abstractions is hiding all irrelevant data about an object in order to reduce its complexity. A real-world example would be like this: You (the Object) are arranging to meet a Friend and are deciding what to tell them so they can find you. You tell them where you are located and what you are wearing. This is the data that will help your friend (the Procedure) find you. There are lots of other data you could of told your friend such as your favorite film or genre of music but this would be irrelevant to the current situation. However, since entities can have a number of abstractions, they may be relevant in another procedure.

 

Encapsulation

Encapsulation is when an object encloses all it’s functionalities, so that all of it’s internal workings are hidden from the rest of the Application. A real-world example would be: Power-Steering in a car. Power Steering is a very complex mechanism with lots of components working together to turn the wheels into a particular direction. But to a driver, if the steering wheel is pushed in a particular direction, so should the wheels.