The OOP Adventure
Posted by Drew on December 25, '08
I've been digging deeper into more advanced PHP stuff, and I'm now delving into the Object-Oriented aspects of PHP 5. I know all the theory and everything with OOP, but the actual practice of it is slightly (well, a lot), more difficult.
Practice Makes Perfect
I'm going to rewrite the little news management CMS that runs this site in OOP. Object-Oriented Programming has a vast amount of features and benefits over procedural programming. The system will be easy to implement, as well as easy to expand upon, adding new features. I've seen first-hand the drawbacks with procedural programming because I haven't been able to expand the CMS the way I would normally want to. With OOP, those options will be easier. I can write new functionality into the individual methods of the classes, and be able to expand and write new sub classes and interfaces without affecting the overall design pattern.
Easier Said Than Done
Obviously, this is something much easier said than done. I've found, in general, this is the case with OOP. In theory, it starts to make sense, but in practice it becomes more daunting and confusing. There is greater planning that goes into the code than just playing around. You have to build your inheritance in a certain way as to maximize the efficiency of the system without getting in the way.
I'm reading a good book right now on PHP5 that is helping with some real world examples. I just wrote a very simple Mailer Class to use on contact forms for sites. I got tired of having to rewrite the script, and I thought it would be good practice. I have a lot to learn, but as with everything I've done thus far, I'll just learn it along the way. I want to make the system easily expandable, so that as I learn more I can easily adjust it. It should be a good project.
Oh Yeah, Merry Christmas!
I hope everyone had an enjoyable holiday! Enjoy it, because it's almost over :)
Comments are now closed.