Is ASP.NET MVC an erroneous implementation of the MVC architect pattern?
Asked Answered
A

1

7

Background: I have been thinking about this for quite some time and I haven´t found any good answer to it. After working for some time with WebForms and periodically with MVC 2,3 and 4 I still do not understand how ASP.NET MVC can claim to be an implementation of the MVC pattern.

One of the first thing I learned about MVC (pattern) is that it is cyclic - meaning that the View uses the Controller which updates the Model which updates the View - and this way it goes, round and round. Naturally with the User in the circle to input new instructions/data etc.

However, the ASP.NET MVC is not really a cyclic implementation, which is nicely demonstrated in the colored image below from W3CSchools. I have also seen this in practice where the View has an instance of a Model and the Model is updated from the Controller but where the Controller is also responsible for updating the View after the Model has been updated.

Question: Is the ASP.NET MVC erroneously implemented by conscious and should it be seen only as a proprietary interpretation or have I misunderstood the rules of the MVC pattern?

ASP.NET MVC MVC Architectural pattern

Ahvenanmaa answered 29/8, 2013 at 9:15 Comment(5)
Good question. The other implementations of MVC frameworks that I've seen isolate the view from the model. iOS and Android development are examples. In ASP.NET MVC, you can use the model inside the view.Redmund
Yes it's wrong. Mostly because the original 1.x version took Rails as template (which actually implements a strange bastardization of PAC and PageController mix). The current ASP.NET MVC versions are still suffering from this choice.Cyrie
Would mark as answer if I could.Ahvenanmaa
If it can fit in the "comments field", then it is not worth posting as answer. IMHO users with 10k+ points should not be rep-whoring.Cyrie
Unfortunately, Web applications have several restrictions that make a traditional "pure" mvc model impractical, thus most web-based MVC frameworks have to make concessions and tend to focus more on separation of concerns than the pure m-v-c. Web apps are stateless, and often much of the presentation logic is split between server and client.Tridentine
K
0

The (Database) Model does not update the view, the controller updates the view while passing the View Model if you use separate view models (which you should)

Kaduna answered 29/8, 2013 at 9:58 Comment(9)
In ASP.NET MVC yes, but this is not implied in the MVC pattern as far as I know. Instead, in the pattern the Model should update the View, with no interference from the Controller. I am not sure that I agree that the model is equal to the database. I see the model as a representation of a data model. Besides, does not answer my question.Ahvenanmaa
Well if you read the wikipedia article it says that the MVC pattern has evolved and that is exactly what is happening with the current web development trends This first MVC concept defined Controller as "the module that deals with input" (similarly to how the View deals with output). The Controller, in modern applications of the 2000s, is a module, or an intermediary section of code, that mediates communication (between the Model and View) and unifies validation, using either direct calls or the Observer — to decouple the Model from the View in the active Model.Kaduna
Yeah, sure, but to evolve is not the same thing as going in all possible directions while maintaining the name. That´s why we have MVVM, MVP, DCI and more that all derive from the MVC pattern but with its own traits. Note: Comments keep changing on me; The fact that the controller deals in communication 'between the Model and View' don´t say anything about the direction of the communication. I still think that a true MVC should be cyclic and hence, communication should only be from view to controller to model to view.Ahvenanmaa
See @jeff-sternal 's answer (https://mcmap.net/q/1630033/-is-asp-net-mvc-a-real-mvc-pattern) in an other SO question about the MVC patternKaduna
Our concerns are not the same, if the definition of an MVC is "Splits user interface interaction into three distinct roles" then pretty much anything is an MVC.Ahvenanmaa
@Ahvenanmaa "Instead, in the pattern the Model should update the View". If this is the case, then I think all implementation got it wrong. In iOS for example, the View is ALWAYS updated by the controller. I don't think the model should know about the view.Redmund
I don´t mean explicity. It could be done with events and/or bindings etc. But I was thinking the View should know about the Model and the Model could raise events when updated and upon which the view could update the bindings.Ahvenanmaa
Is it not just a limitation of the technology? in a web client/server context, something needs to sit between the view & the model, so it might as well be the controller. in a more stateful context, like mvc in the browser, then it could work as you've outlined.Pilot
@SimonHalsey , that problem was solved in ~2000th, when Java community introduced Model2 MVC pattern. Which is one of reasons why some of us use term "MVC-inspired patterns", because you cannot do the classical MVC (with persistent model layer and observers) on th web. Of course that is not a valid excuse for all this Rails-like crap, that has flooded frameworks in all the languages.Cyrie

© 2022 - 2024 — McMap. All rights reserved.