Sounds to me like you are pretty much on the right track bearing in mind that PHP is not the bes language to learn OOP. Even your taskmanager sounds good, i wouldn't bother with reading up on design patterns just yet. They are indeed very important and you should definitely study them, however having spent an year or more doing OOP helps you understand them better. (others will disagree).
Don't worry about classes become too big either if all the code belongs in one class it can't be helped. If you look at a fairly large java program you will find classes that range from 20-30 lines to 2000+ lines.
Chris Neale wrote:
This is a long one - I'm trying to get to grips with my understanding of OOP.
I'm not sure that I understand object oriented programming as well as I could to benefit from using it in PHP. Although I've used it to produce working applications, of the few objects I've produced nearly all have carried too much weight and functionality (one object for both HTML generation and DB interaction etc) and several have been extensions of the others.
I was hoping someone might be able to check my logic.
One of the main functions of the application I'm working on at the moment, my first use of OOP in PHP, is to iterate through a hierarchy of retail outlets and extract information from a database based on each location in the hierarchy. A template SQL statement is parsed and parts are replaced with information from the hierarchy. This query is then executed, and the results are placed in a table within a static HTML file stored in a directory structure which mirrors the structure of the retail outlet hierarchy. I've done it this way because the traffic to the site is expected to be high and the information changes infrequently, so static pages will ensure good performance.
The way I've written the application isn't up to much IMO, using objects in a primitive way akin to a PC newbie using the CD ROM drive as a coffee cup holder - ie. does the job but it's not quite how it was intended to be used.
I've got one big object (treeMapper) that does everything, which includes (over and above the database functions, file input and output, HTML generation and string formatting). It has two main methods. Process() and taskMaster(). The first method iterates one unit through the hierarchy and then calls taskMaster() which takes values Process() has changed in the object and uses them to query the database and to format the results into an HTML table and output to a file (as described above).
-- Raditha Dissanayake. ------------------------------------------------------------------------ http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php