16

I'm a student but I am hopefully moving into the software industry soon. There seems to be a lot of hype about the MVC software pattern. I noticed that PHP frameworks are often MVC, what about non-web languages.. is it the same with them? For my masters dissertation (C++), I chose the MVC pattern because it nicely separates out the logic and user interface.

In industry is it used a lot? If so, what are the main reasons and what are other competing, popular designs?

4
  • 13
    MVC is simply a popular implementation of separation of concerns. SoC is what's important, not MVC itself.
    – Raynos
    Jul 5, 2011 at 12:56
  • 1
    You might want to check Martin Fowler's 'Catalog of Enterprise Application Architecture' for some alternatives/variations on MVC that might suit better specific applications: martinfowler.com/eaaCatalog/index.html
    – Mchl
    Jul 5, 2011 at 13:04
  • 3
    Also note that a lot of things that are labelled 'MVC' are in fact not really MVC, but rather follow the (newer) multi-tiered application model: data storage - logic - presentation (which, IMHO, makes more sense anyway).
    – tdammers
    Jul 5, 2011 at 13:42
  • MVC predates web programming, if that tells you anything.
    – Jeremy
    Jul 5, 2011 at 18:35

7 Answers 7

6

MVC gets a lot of hype and use because it is a very useful pattern for its domain.

MVC encourages separation of concerns. This can simplify development if it is done right. Any application which displays and/or modifies data contained in a datastore will have the MVC functionality, but it may not be separated. Not splitting the components is likely to introduce undesirable coupling between the concerns.

With MVC it should be relatively easy to change the front-end interface (View) of an application without modifying either the controller or model. This may be desirable if you need to allow access from a smartphone, the Web, and one or more applications.

For large teams MVC may allow better use of resources as developers can be tasked with work in one of the layers, and may not need a lot of skill in the other layers. Depending on the overhead of co-ordinating resources, this may be more efficient.

12

Yes, it is used a lot. iPhone/iPad applications are all set up as MVC. I've seen lots of asp.net MVC apps lately.

MVC allows for more flexibility down the road and really encourages developers to write separate code for each function. Makes it easier to maintain.

1
  • Apple's Cocoa framework (used on MacOS X) is the evolution of NextStep, which dates to the late 1980's. NextStep, Cocoa, and Cocoa Touch (used in iOS) all share heavy use of MVC.
    – Caleb
    Jan 30, 2012 at 3:45
4

It's in vogue at the moment.

Never underestimate the power of hype. Soon, someone will come up with something else that's newer, shinier and easier to understand, and everyone will be decrying MVC as the root of all evil (happened to webforms), or there will be so many people using it that the more grizzled veterans decry it as a "management bull**" thing (happened to XML). Or there will be a shift to some other pattern because MVC "isn't flexible enough for the super-hard problem I need to solve" (static-typed languages vs dynamic languages).

At the end of the day MVC is a framework approach that is suitable for a number of problems that web programming throws up. It'll be around for a while but I imagine the reason most people are using it is to be buzzword compliant.

EDIT

Please note: I'm well aware that the MVC pattern has been around for years, and has been used on frameworks before asp.net MVC. I'm just saying it's pretty popular at the moment so it's getting more press than other approaches. I use MVC for all my personal projects, and have been using it on commercial projects as well (I'm a .net developer).

This was not a rant.

6
  • 7
    -1 for: 'At the Moment', unless you consider for example the beginning of Smalltalk or Java/Swing as a technology of the Moment, MVC is a little too old for that.
    – keppla
    Jul 5, 2011 at 12:06
  • 4
    Except "in the moment" is fairly accurate; MVC was hardly used up until recently that I'm aware of, except for in the Java world. Everywhere else it wasn't used until around when Rails became popular. Jul 5, 2011 at 12:22
  • 4
    Most GUI-Frameworks (non-html) i encountered used MVC, it did not seem 'hardly used' to mee the last 10 Years.
    – keppla
    Jul 5, 2011 at 12:31
  • 1
    Actually, MVC already got out-hyped by MVP in some parts of the universe. Jul 5, 2011 at 13:12
  • 3
    Personally, I hated Webforms long before ASP.NET MVC was even a concept. Sometimes things are popular because they're actually the best option in most cases - and yes, they may be replaced by something newer and more powerful, but so what? That's progress, not hype.
    – Aaronaught
    Jul 5, 2011 at 14:46
3

From my experience, it isn't used as much as it should. It's a much better model than some of the alternatives, but it's only getting a lot of hype in the last few years; because of that there's a lot of legacy cruft that people are afraid to convert to MVC or afraid to use MVC for future work because it's outside their comfort zone.

1

I think you'll find that the Stack Exchange family all run on MVC

1
  • Awesome, didn't know that +1
    – ale
    Jul 5, 2011 at 12:35
1

ASP.NET MVC has gained a lot of prominence for Web Applications, since .NET is used a lot in the industry.

Microsoft web applications evolved from Classic ASP to ASP.NET, which is based on Web Forms (to allow the skills VB6 Win Forms developers already had to be easily translated to the new frontier of the web).

Unfortunately, Web Forms is state-based and HTTP (that the web is based on) is stateless, so a lot of nasty workarounds due to things like viewstates were needed.

ASP.NET MVC allows the skills WebForms developers have to be translated to a web framework that has good SoC and that has had a lot of effort put into being testable (since WebForms isn't very testable, the MVC team have put a lot of effort into the framework).

That said, it's not a panacea/silver bullet, and like any framework, there are times to use it and times not to use it. Hopefully people won't use it to try to solve everything, after all: when your only tool is a hammer, every problem looks like a nail.

1

It's just a moment in history as MVC is a couple very very simple concepts that happens to have received hype from a couple specific frameworks that which featuring it prominently in their marketing material. It also happens to jive with much of the good practices that have emerged in software development. This applies double for pseudo-stateful development such as HTTP; so much so that I only know of one other truly different "pattern" that is used in the web world - the much-maligned ASP.Net WebForms event-based model.

I'm honestly a little surprised there's enough there for a whole dissertation.

But to answer your question. WebForms is a narrow slice of the web-pie mostly making its home in intranet business applications. Spaghetti-coded pages with no real pattern probably make up a decent amount of the Venn diagram but pretty much anything which is a framework is at least heavily influenced by MVC so your short-answer would be a resounding YES.

1
  • @geroge: Thanks for the answer. Ha.. don't worry, the software included with my dissertation uses MVC.. it's not actually on MVC!
    – ale
    Jul 5, 2011 at 13:45

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