What is Object Oriented Programming (OOP) ?

What is Object Oriented Programming (OOP) ?

Hello everyone, in this article we are going to talk about Object Orientated Programming and plusses minusses and why should we use Object Oriented Programming methods.

Now lets get started

First, I want to talk about why we are using softwates and why OOP is more useful, what kind of supports does OOP technic provide us.

We use softwares to help us. When our tasks get heavy, the softwares have to have much specification. More specification means more complex structures. At procedural development there is no classes and adding specifications to our program is getting difficult. To get development easy we are usong the development methods like OOP.

So What is Object Oriented Programming
In Object Orientated Programming, we define everything as object and the objects are performing the logical processes. With OOP we are decreasing the complexibility and increasing the readibly.

I want to give an example about OOP. Now I want you to think a car. We can classify a car as a vehicle. I mean car is a subclass of a vehicle. All vehicles have same properties and same functions also have different functions and properties. So in Object Orientated Programming we define a class named Vecihle and have common methods and properties of all vehicles. Now we have subclasses named cars, motorcycles, bikes, aircrafts and we can increase the examples. All vehicles have specified properties and methods belongs to them. And now we derive a Car class and we need use the functions belong to Vehicle Class. This is the class deriving methodology of OOP.

What facilitating does OOP provide for us?

  • We define everything as object with all properties and methods. So this keep our project development tidied up.
  • OOP lets us to derive new classes from an upper class. We can use upper classes' functions. So we can write same codes just one time to use everywhere.
  • We can share or protect the classes from other classes. We can let the other class to be derived from class or not to let them.
  • The classes or objects which we created in a project, we can use this class or object in every projects.

Now, I want to talk about what is class and object a little bit.

Object is a keeper. It keeps all properties and methods of what it belongs. When we create the object with a variable, we can use all of methods and properties of that class.

Class is a behaviour of objects. We can tell the objects to do somethings with classes. Classes are the bridge between objects and program thread.

Basic Specifications of Object Oriented Programming

There are 4 basic specifications of Object Oriented Programming. These are:
  • Inheritance : We can create a class that contains all properties and methods which is in need by the other class. We can derive new classes from this class and derived class can use these methods.
  • Encapsulation : We can hide and show the properties and methods. If we do not have to show any property we can do not let the other classes to use it. So we are being encapsulated it.
  • Abstraction : We are defining the properties and method of an object. So we are abstracting this class from other classes.
  • Polymorphism : We can use a derived class for other purpose. These classes can be used by other classes.

When we created an object in the program, it stays on memory. So we need to destroy it when we do not need it. So we call constration and Destruction methods. With these methods we will define some processes when the class constructed and destructed.

Now we will define some class as examples. ı will use C# for below class examples.

class TheCar

    public    Color  bodyColor = Color.Black;
    public    Color  tyreColor = Color.Green;
    public    string brand  = "Mercedes";
    public    int       manufacturedYear  = 2018;

   //Construction class: this will run firstly when initialized
   public void TheCar() 
       Console.WriteLine('TheCar class has been initialized');
   public void setBodyColor(Color _bodyColor)
       this.bodyColor = _bodyColor.;
   //Destruction Class: This class run at the destruction
   public void ~TheCar()
       Console.WriteLine('TheCar class has been destructed...');

Above code block we have created a class named TheCar and we have specified some properties and method. Also we defined constructor and destructor.

below code block will create a class and run a function that is inside of that class. And we will run a function that is inside the class name setBodyColor.

TheCar car = new TheCar(); 

That is all in this article.

Keep up with my articles.

Have a good object orintated programming.

Burak Hamdi TUFAN


Share this Post

Send with Whatsapp

Post a Comment

Success! Your comment sent to post. It will be showed after confirmation.
Error! There was an error sending your comment.


  • There is no comment. Be the owner of first comment...