The Importance of Object-Oriented Programming

I recently overhauled a script (that I had not written) in PHP that was quite long and converted it into an object-oriented variation. Although the process may have taken longer than I would have liked in the end I was able to see a few improvements.

Cleaner Code
First, my code was just cleaner and more concise. I no longer had to scroll through line by line searching for certain methods. The glory of object-orientation is the modularity you are able to gain. It just makes sense to organize right? Your mom always told to clean your room, so it is about time you start listening.

Code Durability
When it comes to use code we want to use it over and over again. Can you imagine trying to use a 1000 line script over and over again? What if you only wanted to use 10 lines in the middle of the script? The task is daunting and stressful. Reality sets in and you discover that this script is now in 5 different locations and 5 different variants. Object-orientation takes care of this for you. Place your classes into a single library so that they can be used by all applications.

Future Expansion
The greatest single factor for object-orientaiton (in my opinion) is extending classes and integration. If I need a class to have a few extra methods or properties it isn’t a big deal. I just extend my class. Try doing that with a single script.

In the end, the script now has a significant performance improvement and I can integrate it’s features into other applications that require it’s functionality.