Page 1 of 1
Do you use MVC pattern?
Posted: Tue Nov 22, 2005 4:10 pm
by Ree
So I've been reading up on MVC lately and I think I do understand the concept. Right now I'm really interested if casual PHP programmers use it that much

. Also would be nice to hear your reasons on your decision and any comments you might have regarding MVC usage.
Posted: Tue Nov 22, 2005 5:33 pm
by RobertPaul
I would if I had a solid grasp of it. And of OOP in general. But I'm getting there.
I really do like the general idea behind MVC, though. I just need to work on the finer points of implementation.
Posted: Tue Nov 22, 2005 5:48 pm
by Roja
Just wanted to say, *excellent* phrasing of the question, and the poll answers. "Yes, as often as I can" shows a clear understanding that its not always possible.
Nice to see.
Thats what I chose. In my work life, I'd say my code is strongly MVC. In my hobby work, while its not currently MVC, I'm pushing hard to get it there. (The upcoming version of Blacknova Traders is FINALLY over the 50% templated mark! Woohoo!)
Of course, there are strict interpretations of MVC, and loose. I'm fairly strict, but every so often, you have to have some logic in the template.. as long as its not actually processing, I think thats solid.
Posted: Wed Nov 23, 2005 3:09 am
by Maugrim_The_Reaper
A bit like Roja, my current project (a game) is primarily an MVC structure. Its a custom design (there are pre-made frameworks all over the place these days) but it works quite well. Its one of those patterns you should read up in prior to use - even if you use a ready made framework it helps to understand all the principles involved rather than jump in the deep end without a clue.
As for casual use, I'd say yes. Most of my development is done as a hobby, and nearly all as open source. It largely depends on what you need. I made up a generic MVC scaffold for re-use, it works but its not a strict pure MVC implementation - nor is it a full fledged framework. I am using it in about 4 projects so far, so its seeing a lot of use and so far very few problems.
The documentation for a PHP MVC framework would be useful - PHP specific MVC documentation is far and few between.
Posted: Wed Nov 23, 2005 10:42 am
by onion2k
I googled and found a definition .. and I have no idea if I use it or not. I doubt it. My understanding of compsci terminology is rubbish.
Posted: Wed Nov 23, 2005 10:59 am
by sweatje
onion2k wrote:I googled and found a definition .. and I have no idea if I use it or not. I doubt it. My understanding of compsci terminology is rubbish.
MVC explanation
Posted: Wed Nov 23, 2005 11:16 am
by trukfixer
onion2k wrote:I googled and found a definition .. and I have no idea if I use it or not. I doubt it. My understanding of compsci terminology is rubbish.
in a nutshell (a very basic nutshell) : separate display from logic (A.K.A. what I use Smarty Template system for)
you have code logic in script A , and you have the template (html, xml, whatever) in script B and teh controller that put sthe two together in Script C ...
Posted: Thu Nov 24, 2005 3:17 am
by Maugrim_The_Reaper
Gets even more complex though

The MVC is a challenging pattern, and there's still debate about whether its actually suitable in PHP.
That hasn't slowed the development of MVC Frameworks though.
Posted: Thu Nov 24, 2005 7:56 am
by Buddha443556
Voted sometimes. Do you use MVC pattern? Yes. I study it and it sometimes inspires me. That's about all I ask of any pattern.
MVC pattern talks a lot about separation. I think people tend to focus on this separation and lose sight of the purpose of MVC. The purpose of MVC is to make maintaining your code easier. Has any of the PHP projects that claim to implement MVC achieved this purpose? I don't know, I'm too busy maintaining my own code.

However, maintainability might be a better way to judge such projects than separation. Maintainability at least can probably be measured.
Achieving seperation of model and view is the easy part, being able to easily maintain that code ... that's tricky part.
Posted: Thu Dec 01, 2005 1:27 pm
by alvinphp
I use MVC not just in PHP, but with development in any language. The degree of use depends on the application I am working on. I have yet to work on a program (even a one pager) where I am not able to use MVC structure to some degree. The end result, for me, is an application that is easier to work with and understand.
And MVC does not fit like a glove for any language as you have the database side of an application which has its own model and controller in the form of stored procs, triggers, views, etc.
On a side note, my personal view on this subject is that things like MVC structure and UML design is severly lacking in the PHP community. The focus is so much on making sure your code is bug free and efficient (unit testing), and so little time is spent on making sure what you build is what is actually needed. If you are building for yourself it does not matter, but if you build for someone else then pre development planning is (IMHO), by far the most important aspect of the project.
Posted: Thu Dec 01, 2005 1:39 pm
by Chris Corbyn
onion2k wrote:I googled and found a definition .. and I have no idea if I use it or not. I doubt it. My understanding of compsci terminology is rubbish.
There's a pretty good chance you do. To put it very simply... it's keeping what the users see away from the logic that goes into it... templating is a huge part of it.
Posted: Thu Dec 01, 2005 3:01 pm
by m3mn0n
I've been using it a lot more recently since I've been playing around with PHP5 OOP alot lately.
But normally, it depends on if it's a personal project (unlikely) or a client's project (more likely)
Posted: Thu Dec 01, 2005 3:15 pm
by BDKR
Buddha443556 wrote:Voted sometimes. Do you use MVC pattern? Yes. I study it and it sometimes inspires me. That's about all I ask of any pattern.
MVC pattern talks a lot about separation. I think people tend to focus on this separation and lose sight of the purpose of MVC. The purpose of MVC is to make maintaining your code easier. Has any of the PHP projects that claim to implement MVC achieved this purpose? I don't know, I'm too busy maintaining my own code.

However, maintainability might be a better way to judge such projects than separation. Maintainability at least can probably be measured.
Achieving seperation of model and view is the easy part, being able to easily maintain that code ... that's tricky part.
I like your post and agree. I started using it before I knew what it was (same thing with the registry pattern) and have found it to be a huge benefit.
I might add that I think having easy to view or see (other then reading the comments) potential paths of logic really makes code easy to maintain. At this level, it doesn't even have to be OO to be easy to grok.