Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is MVC so popular?

I was originally going to make this a longer question, but I feel like the shorter I make it, the better you'll understand what I mean.

  • The MVC architectural pattern has 3 dependencies. The View depends on the model. The Controller depends on the View and Model. The Model is independent.

  • The Layers architectural pattern defines N - 1 dependencies, where N is the number of Layers.

Given three Layers: Model, View, and Controller, there are only 2 dependencies, as opposed to 3 with traditional MVC. The structure looks like this:

View ---> Controller ---> Model

[View depends on Controller, Controller depends on Model]

It seems to me that this style accomplishes the same goals and produces looser coupling. Why isn't this style more common? Does it truly accomplish the same goals?

Edit: Not ASP.NET MVC, just the pattern.

With regard to griegs's post:

  • As far as mocking, Layers still allows you to use the Command Processor pattern to simulate button clicks, as well as any other range of events.
  • UI changes are still very easy, perhaps even easier. In MVC, the Controller and View tend to mesh together. Layers creates a strict separation. Both Layers are black boxes, free to vary independently in implementation.
  • The Controller has 0 dependencies on the View. The View can be written, and time can still be saved with loose coupling.
like image 917
Mike Avatar asked Sep 02 '10 01:09

Mike


People also ask

Why is MVC famous?

UI changes are still very easy, perhaps even easier. In MVC, the Controller and View tend to mesh together. Layers creates a strict separation. Both Layers are black boxes, free to vary independently in implementation.

Why is MVC good?

MVC platform supports the development of SEO friendly web pages or web applications. Using this platform, it is very easy to develop SEO-friendly URLs to generate more visits from a specific application. This development architecture is commonly used in Test-Driven Development applications.

When did MVC become popular?

Throughout the 1980's and early 90's, the MVC pattern was primarily used in desktop applications. But by the late 1990's, it became pretty popular within web applications. In today's web applications, the MVC pattern is a popular design choice for organizing your code.

Is MVC obsolete?

Is the framework outdated? ASP.NET MVC is no longer in active development. The last version update was in November 2018. Despite this, a lot of projects are using ASP.NET MVC for web solution development.


1 Answers

Because you decouple the interface from the controller making changes easier.

Also consider the scenario where you need to get started on a project but the artwork won't be ready for weeks or months. Do you wait or do you write all the code required for the pages and simply then wire up the view to the controller.

At least that's what we did and we saved months.

Also it made UI changes easier to cope with because there wasn't any code in our aspx pages that did anything.

Our tests were also better as we could mock up anything including button clicks etc.

And if you're talking about the asp.net-mvc framework, there is no code in the aspx files and no viewstate etc.

like image 85
griegs Avatar answered Sep 19 '22 18:09

griegs