Once upon a time in a far away land….
Or at least when I was rocking only 2 screens, a door for a desk, and spent a majority of my time using the Cisco CLI…. Actually let me back up before that and circle back.
Well to do this I would have to either learn Perl or PHP. Because I had been hearing chatter about this cool new language called PHP and Perl was starting to be called “outdated”, to me it was a simple choice. I purchased a book from my college’s bookstore and set out during Christmas break determined to become a master. To prove my skills, I build a forum from scratch that is still live (mostly for historical purposes) today. An this was the beginning on my coding career.
Now we have arrived at the beginning of my tale…..
I wrote many apps and scripts using PHP. In the beginning I was writing what I call today “spaghetti code”. Random files and lose functions everywhere. Site sections organized by folders all with their own functions. This is what is called “functional” code. While functions may be reused throughout the script and some naming conventions are used to keep things straight, it’s still what I would call a mess.
As my skills grew and my web applications were becoming more complex, I decided I had to learn a better way. Again, I went back to the bookstore and this time bought the PHP 5 Advanced book. Which coincidentally, I still keep above my desk as a dust collector. This book opened my eyes to OOP or?object oriented programming. A whole new way to organizing and app to be able to reuse and extend code cleaner and more efficient.
These days, there is nothing I write which is not OOP. Even if I am just added a few filters to a theme, or writing a 1 file plugin, I still put everything inside an object. I think of it as laying the foundation for the future. By starting off well organized, it make future changes easier for myself and other developers. I like to think of objects as Legos. Building code in blocks which fit into other blocks opens up a world of creativity and expansion. When things are extendable you are only limited by the imagination of any developer who comes across your code. People can build solutions on top of your solutions. You can build code once and not have to do it all over again next time.
OOP is the way to be!