Do you use MVC pattern?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply

Do you use MVC pattern?

Yes, as often as I can
12
50%
Usually
6
25%
Sometimes
3
13%
No, I don't
3
13%
 
Total votes: 24

Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Do you use MVC pattern?

Post 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.
RobertPaul
Forum Contributor
Posts: 122
Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY

Post 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.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post 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
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Post 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 ...
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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. :oops: 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.
alvinphp
Forum Contributor
Posts: 380
Joined: Wed Sep 21, 2005 11:47 am

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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)
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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. :oops: 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.
Post Reply