Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Hey... its XMAS Eve and something is bugging me... yes, I have work on my mind even when I am on holiday. The vast amount of frameworks available for PHP now use MVC. Even ASP.net has its own MVC module.

I can see the attraction of MVC, I really can and I use it frequently. The only downside that I can see is that you have to fire up the whole system to execute a page request. Depending on your task this can be a little wasteful.

So the question. In a professional environment is this the only way to use PHP nowadays or are their other design methods which have alternative benefits?

share|improve this question
    
What does "fire up the whole system" mean, and how is this required by MVC? MVC is just a design pattern. If you're using PHP, you're already using server-side code, and you can't really have an interactive website without client-side code, so I fail to see what part of the "system" is not being used. Or why that part MUST be used when you use MVC. –  Matthew Read Dec 25 '10 at 5:13

4 Answers 4

no. What pattern you use always depends on the task your programm/script has to perorm. Just yesterday I had to solve this:

  • show the mtime of two files
  • show number of temp files in a folder
  • allow deleting all temp files with one click
  • web interface

I know one could argue that a nice reusable MVC sollution would be cleaner, but I choose a 20 lines of sequential code. Why? It is fast. It is small. And every minute I spend on this is a minute I can not use on my main project.

(let the hate begin!)

share|improve this answer

The thing to think about is not whether using an MVC framework is justified, it's maintainability. Sure, it may be small now, but will it always be?

share|improve this answer
    
+1 for size helping maintainability. ALso another thing to remember is the execution time limit which is why why you usually want to keep things as small as possible when you can. –  wildpeaks Dec 24 '10 at 21:10
    
I am not really talking about whether you need to use an MVC framework. It is more about the MVC pattern in general when designing an application. –  JasonS Dec 24 '10 at 21:13

Well there are a lot of other approaches.

MVC is just popular because it suits most situations (or better said can be used in most situations) and has established itself as a de-facto standard.

What can be said is that every programming/design pattern - or more specific architectural - depends on some classification.

Those are often (of course they can be devided further):

  • User Interface (pretty images, forms etc)

  • Application (your application logic and stuff that needs to be secured from the client - ak lot of that can often be done in the user inteface, eg. by javascript)

  • Database - self explaining

  • Infrastructure (very basic stuff like hard disk, server systems, network etc.)

Of course there is always the naive, procedural straight-forward approach but also a lot fo other patterns that can link and structure the access and controlling to these basic layers.

Mvc is one of them. But here are some example of others:

http://en.wikipedia.org/wiki/Model_View_ViewModel

http://en.wikipedia.org/wiki/Model_View_Presenter

http://stackoverflow.com/questions/140098/is-mvc-ars-preferable-to-classic-mvc-to-prevent-overloading

And here a lot more:

http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)

share|improve this answer
    
I hope you meant native and not naive procedural straight forward approach :P –  andre Dec 25 '10 at 13:06

MVC is usually the most natural way of separating concerns in medium to large web applications. Nobody says you have to do it that way. If your domain suggests another way of separating the application into manageable pieces then you should do it that way. Chances are high though that you'll settle on a variation of the MVC pattern if you separate the application logic properly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.