CuriouSTEM

View Original

What Is Object-Oriented Programming?

Programming has evolved massively since the early days of FORTRAN and other limited-use languages in the 1960s. Structured programming was the initial approach to programming introduced with the advent of programming languages. This method works by listing operations sequentially. If you wanted to perform simple functions like addition, your program would most likely be entirely sequential, even today. Due to the lack of emphasis on structure, breaking up code into objects isn’t necessary.

But what are objects? Since the introduction of Java in the mid-90s, object-oriented programming has become a popular style among newer programmers and many old ones alike. This involves breaking code into objects that perform a certain function in the code.

Imagine a program that takes in two dates and tells you the number of days between them. Think about the logic behind this program. You would first need to save the two dates and use a number of variables in the process (day, month, and year). The second large step is to calculate the number of days based on the calendar (which is just fixed amounts of information). Something like this could be solved structurally by just putting line after line of calculations and declaring constants (values).

An alternative could be embracing OOP. By putting each of the two steps into objects, we can establish a number of different characteristics of our program. Firstly, the program becomes easier to read. A single “main” method could call both parts, indicating the order of their execution and the variables they would use.

A second benefit is the ability to organize increasingly large programs. Another developer or you at a different point in time can establish the formulas and other math behind the scenes. This process is called “information hiding”. This can expand your ability to collaborate with other programmers, which is essential to dealing with multiple files across several programmers working on one large project.

Using these tools, more and more programmers are embracing objects to group code and increase efficiency and their ease of programming simultaneously. As programs become more complex, many predict the use cases of this modern form of programming will continue to increase.

Picture Source: geeksforgeeks.org