Thanks - very useful way of looking at things. I think I'll opt for applying
this principle to the way I plan to improve my system. Currently far too
bulky. Of course, now the project has progresse, finding time to refactor
and effectively build most of it from scratch, is quite hard.

Cheers

Chris

-----Original Message-----
From: Justin Patrin [mailto:[EMAIL PROTECTED]
Sent: 30 January 2004 17:19
To: [EMAIL PROTECTED]
Subject: [PHP] Re: OOP methodology


Wow, that's a lot of stuff in one class. Personally, I've started using 
the MVC (Model, View, Controller) architecture. Basically what it does 
is seperates Data logic from Display logic and Control logic. Here's how 
I've been using it.

Model: Holds and deals with all data for the program, such as database 
connections / queries, session data, data consistency. I am currently 
using classes which use PEAR DB_DataObject for DB connections, querying, 
and data storage.

View: Deals with displaying of data from model. ONLY does displaying, no 
processing. Very minimal logic only associated with outputting. 
Currently, I am using Smarty entirely for the view. Little no no PHP 
code, only Smarty. The View in this case is just a smarty template file.

Controller: Handles requests from the browser. Instantiates Model and 
View, calls functions in Model to alter its state (updating from 
$_REQUEST vars, for instance). Chooses a view and then tells the view to 
display. For me, this is all home-grown PHP.

This architecture can be much more complicated in, say, a C++ program, 
but the Server/Client pattern built into web programs makes it much more 
simple. The reason that I use this particular architecture is that it 
factors all of the pieces of your program very nicely. Later, if you do 
things right, you can use a single screen from one program in another 
with minimal editing.

Here's a few pages that discuss MVC:
http://ootips.org/mvc-pattern.html
http://st-www.cs.uiuc.edu/users/smarch/st-docs/mvc.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield.  Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to