Object-oriented Programming is a programming practice, that is using Class blocks to group certain object properties or methods into one definition. This way, it makes the code more manageable. In this post, I will explain the core principles of object-oriented programming.


What is a Programming Object?

var customer_name;

Before object-oriented programming, there were only variables. You can think of the variables like small boxes in memory, they are created when the software/script starts running and they hold all real-time data in memory. But with very complex scripts or codes, it becomes a huge task to manage all those variables.

For example; suppose you have a list of customers you want to show on your software. You need to hold names, emails, phones, etc. all in memory for each of the customers. How many variables would that take? And how would you name them?

var customer1_name, customer1_phone, customer1_mail;
var customer2_name, customer2_phone, customer2_mail;
...

With object-oriented programming, variables are initialized using Class definitions. This way you have only one variable (that is called object to differentiate) with many small drawers. So you can navigate to information using this object reference easily. See it in the example below:

var customer1 = new Customer(); /* initialize object */
customer1.name = 'John'; /* set property */

To Be Continued…

Of course, grouping properties is not the only advantage of OOP. There are many other advantages of using OOP practice and I will write about them, too. Follow me on Twitter using the button below to catch all OOP related posts later on!

Follow @metinsaylan on Twitter