Know Your Skills - You Can Be Dangerous In Bad Ways Too
Application development is a skill that some people are taught, and while others try their best, it's often evident when someone has no experience (or is following bad precedence). I came into the PHP world straight from C++ focused college over 6 years ago, and have been learning that ever since. From the first "a college student started it and now you have to support it" day at my previous commitment to the "business application built against a deadline by people that used a text editor" (I almost wish that was a joke).
So I recently had a module in our web application that I've been tasked with revising, so I took the opportunity to port it to another section of the code where all the other modules reside. Why would I do such a thing? Because it was poorly designed. In a non-object language, I guess it could make sense, but even then, this program was designed during the crux of PHP 4 and there would have been better options than what was chosen.
The way it worked was that it had one main file handle the direction of the script, with many others included to dictate their function. Files like actDeleteItem.php, actUpdateItem.php or even actAddItem.php - all accessed via a large switch statement. When you add in the fact that it was also set apart from the main module of the program and was in an obscure area, it boggled my mind even more.
So I went to task (as I have been doing over the past year for other sections of this web application), and have been working on taking those many pages and compiling them into a properly designed PHP class/module. Now I've got nearly 2000 lines of code that have been re-tuned to fit together properly. Likely not near as clean as I could have written it from scratch, but this being such a huge step and it being production-oriented code, functional equivalence was my goal.
And so far, it's working as it was before. But now it's better put together, out of the abstract area of our system and put with the other classes I've developed over the years. If my predecessors had made the proper decisions, I could have saved a decent amount of time on this module alone. Thankfully, I tend to enjoy a coding challenge, and the best part of this is that the extending that I'm going to be working on tomorrow will now be much easier. Here's hoping the people that will inevitably follow me in this job don't think the same thing about my code as I've thought about what I've been left to take care of.
