Page 1 of 2

Do you use the MVC pattern in you applications or not?

Posted: Wed Apr 04, 2007 2:47 am
by Oren
So... do you?

Posted: Wed Apr 04, 2007 3:08 am
by Zu
If the project requires a MVC, then yes. Often a project doesn't require that level of complexity.

Posted: Wed Apr 04, 2007 3:15 am
by Benjamin
I do providing it isn't overkill. It should almost be called Emulated Model View Controller though, as PHP by nature doesn't support true MVC.

I would probably call it something more along the lines of Controller, Executioner, Renderer. CER. That would make more sense.

But thats just me. :wink:

Posted: Wed Apr 04, 2007 3:59 am
by webaddict
Zu wrote:If the project requires a MVC, then yes. Often a project doesn't require that level of complexity.
True enough, but I like the way it works. There aren't a lot of projects that I would do without using some kind of a framework (be it Zend, Code Igniter or my own). Aforementioned frameworks don't force you, but they do guide you into the principle of Model View Controller.

Posted: Wed Apr 04, 2007 8:30 am
by Chris Corbyn
All the time. I beg to differ that it's "complex" once you get used to it. Granted, it took me a long time to really fathom out what goes where, but now I wouldn't find code anywhere near as maintainable without it.

Posted: Wed Apr 04, 2007 8:49 am
by Buddha443556
I do my best to separate the presentation from the model. Any use of MVC pattern on my part is probably accidental because I don't spend much time worrying about patterns.

Posted: Wed Apr 04, 2007 8:53 am
by feyd
Buddha443556 wrote:I do my best to separate the presentation from the model. Any use of MVC pattern on my part is probably accidental because I don't spend much time worrying about patterns.
I'm the same.

Posted: Wed Apr 04, 2007 9:07 am
by Kieran Huggins
provided it makes sense to do so

Posted: Wed Apr 04, 2007 12:02 pm
by Christopher
feyd wrote:
Buddha443556 wrote:I do my best to separate the presentation from the model. Any use of MVC pattern on my part is probably accidental because I don't spend much time worrying about patterns.
I'm the same.
The Model/Presentation separation is probably 80% of MVC. There is no hard and fast rule as to where the dividing line is between the Controller and View, or even what the dependencies must be. So if you write modular code with clear/clean dependencies, the you are both using MVC -- whether you like it or not. ;)

Posted: Wed Apr 04, 2007 12:35 pm
by RobertGonzalez
Buddha443556 wrote:I do my best to separate the presentation from the model. Any use of MVC pattern on my part is probably accidental because I don't spend much time worrying about patterns.
I am along those sames lines... somewhat. My current app I am building for work uses a controller that serves everything through index.php based on page name, that then gets thrust through the page rendering class which implements any modules for that page name, parses that pages template and outputs a page.

If I said it was MVC it would probably make the die hard MVC coders puke, so I staying away from that classification. It is similar, but I would not say I use MVC.

Posted: Wed Apr 04, 2007 12:46 pm
by Christopher
So we have a poll about a little understood pattern that most people are not sure if they use or not... ;)

Posted: Wed Apr 04, 2007 12:55 pm
by RobertGonzalez
In the words of a personal PHPDN acquaintance:
I dunno

Posted: Wed Apr 04, 2007 3:37 pm
by Chris Corbyn
arborint wrote:So we have a poll about a little understood pattern that most people are not sure if they use or not... ;)
That's MVC for ya! I've seen more MVC topics than any other design pattern in my time.

It's always "controller" that gets confuddled with the layers either side of it. Controller is fairly minimal simply passing notes between the other two layers.

Posted: Wed Apr 04, 2007 4:25 pm
by Oren
d11wtq wrote:Controller is fairly minimal simply passing notes between the other two layers.
Yes, that's how I see it.

Posted: Wed Apr 04, 2007 5:17 pm
by Christopher
I think maybe a confusing thing about the Controller is that it is sort-of defined by not being the View. I mean that in the sense that the Controller is the non-output code in the presentation layer. The Controller is about program flow. For example, you may have two views of the same data: tabular HTML and an XML data feed. The program flow is essentially the same, and the Model is obviously the same.

This gets to the essence of separations --- they are about defining modules, especially for reuse. Views are modular outputters. Models are modular data sources. Controllers are modular request managers. And those are the essential modules of an application.