NYCPHP Meetup

NYPHP.org

[nycphp-talk] MVC Framework opinions

Chris Hubbard chubbard at next-online.net
Mon Mar 1 18:30:09 EST 2004


I've used a couple different implementations of MVC. 

You have to define what you mean by MVC as it looks to me as if almost 
everyone implementing MVC pushes the definition(s) in new and 
interesting way. 

I've seen MVC implemented different ways.  For example I've seen:

where you've got a php page which is just a hollow shell that includes 
the worker file;
    index.php and indexWorker.php,
    listing.php and listingWorker.php, etc.

where you've got a single php page which based on the use of the site 
loads/includes different worker files:
    index.php and Worker.php, Listing.php, etc.

where you've got a single php page, a logic page and a template:
    index.php and indexWorder.php and index.tpl

Then I've seen it taken to extremes, where every field in a table has 
four different controllers, add, edit, delete and view.  So to do a 
query you'd do something like $a = getTableField('tablename', 
'fieldname');   ,  and getTableField would connect to the database an 
query the database for that specific piece of data.  Personally I think 
this is silly.  Makes maintain the code brutally difficult.  I'd rather 
write SQL.  Mind you I know how to write SQL.

For me the answer is to not use a formal framework design.  Pick a 
design that works for your level of competency and the particulars of 
the application.  If a version of MVC makes it easier for you to 
abstract the logic of the application then use MVC.  If you are 
abstracting the logic of the application you may find that there is 
another logical framework design/topology that works better.  Make your 
code easy to maintain.   MVC may or may not make your code easier to 
maintain.  As far as I can tell there's nothing inherent in MVC that 
would make code easier to maintain.  It's just as easy to write bad code 
with MVC as it is without MVC.

Hope this is helpful.
Chris


Allen Shaw wrote:

>I'm using Smarty templates now for "my first big project," which is an
>database that was basically ported to php/mysql from ms access.  We extend
>Smarty with a custom class that runs a few extra things (checks permissions
>for different templates and different data processing actions based on
>login, etc.) and then uses Smarty to parse the templates.  It's great and
>very flexible and allows my brain to keep thinking in terms of "data entry
>form, module, etc." as I did with MS Access.
>
>However I feel I honestly have not been able to do as good a job with
>"splitting up logic from presentation" as I'd like to.  It's a judgement
>call and a thread that comes up here and there on the Smarty forums: how
>much do you have to / want to keep them separated?    Since I'm the only
>developer on this team, I have, of course, both a lot of flexibility and a
>lot of chances to write lazy code.
>
>All in all, though, Smarty and our little extension of it, are serving me
>well, and I think I probably am limited more by my own lack of programming
>experience/discipline than by the framework itself.
>
>- Allen
>
>  
>
>>First, what are the pro's and cons to using an established MVC framework
>>    
>>
>in
>  
>
>>general, as opposed to using other strategies to split up logic from
>>presentation? Smarty templates anyone?
>>    
>>
>
>--
>===========================================================
>Allen Shaw                                  ashaw at iifwp.org
>IIFWP Data and                           914.631.1331 x.106
>    IT Services                        http://www.iifwp.org
>
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk
>  
>

-- 
Chris Hubbard
Sr Software Developer
Next Online
425 563 4153





More information about the talk mailing list