Linked by John Collins on Wed 21st Apr 2004 06:42 UTC
The purpose of this article is to give a novice programmer the basic idea of what OOP is, as implemented using PHP. Readers should have a basic knowledge of programming ie what variables are, variable types, basic methods of writing comments, and how to enter code into a text editor.
Permalink for comment
To read all comments associated with this story, please click here.
By writing my common utility functions in nice, well contained classes, I have found that it makes it much easier to work on a project. For example, I wrote a class that interacted with MSN Messenger, and I abstracted away all of the socket stuff into it's own wrapper class. When I was assigned to write a project that monitors an IMAP mailbox, a nice sized chunk of this project was already done! I can just write a new class called IMAPMailNotifier or whatever, and use include SocketWrapper as a member, and now I have instant socket functionality. If I ever need to do MD5, url-encoding, I also have those classes available now. A week later, I was asked to write a project that parsed the Spam folder of an IMAP account, and parsed a header (X-Spam-Header- spamassassin score) and gave an average score for all of the message. It only took me 30 minutes because I had a reusable IMAP class.
Yes, this does mean the original project took longer to do, because I had to spend some time organizing the classes, seeing how they would interact with each other, deciding what members should be private, if anything should inherit anything from anything else, but it pays off. I have easily reusable code. My employer certainly was impressed at how quickly I finished my projects, and it also means that I have to spend less time debugging my project, because I am using code I have already tested.
By writing my common utility functions in nice, well contained classes, I have found that it makes it much easier to work on a project. For example, I wrote a class that interacted with MSN Messenger, and I abstracted away all of the socket stuff into it's own wrapper class. When I was assigned to write a project that monitors an IMAP mailbox, a nice sized chunk of this project was already done! I can just write a new class called IMAPMailNotifier or whatever, and use include SocketWrapper as a member, and now I have instant socket functionality. If I ever need to do MD5, url-encoding, I also have those classes available now. A week later, I was asked to write a project that parsed the Spam folder of an IMAP account, and parsed a header (X-Spam-Header- spamassassin score) and gave an average score for all of the message. It only took me 30 minutes because I had a reusable IMAP class.
Yes, this does mean the original project took longer to do, because I had to spend some time organizing the classes, seeing how they would interact with each other, deciding what members should be private, if anything should inherit anything from anything else, but it pays off. I have easily reusable code. My employer certainly was impressed at how quickly I finished my projects, and it also means that I have to spend less time debugging my project, because I am using code I have already tested.
Just my thoughts!