What's an alternative to MVC?

2019-03-31 21:12发布

Seems like every project I'm on uses a Model View Controller architecture, and that's how I roll my own projects. Is there an alternative? How else would one create an application that has persistent storage and a user interface?

7条回答
等我变得足够好
2楼-- · 2019-03-31 21:12

MVC has been around for a while. It's a time tested and proven pattern. Many frameworks leverage the MVC Pattern. Martin Fowler has deconstructed the MVC into: Supervising Presenter and Passive View.

Architect Christopher Alexander said it best:

Each pattern describes a problem which occurs over and over again in our environment and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.

I'm not sure why you would want to move from MVC. Is there a problem you are encountering that MVC does not eloquently solve? To give you a better answer we need to know more about your problem domain.

Things to take into account when considering patterns/architecture: If you are building something with a Myspace type architecture you'll need a robust architecture (MVC). If you are creating a simple crud interface via the web - almost anything will do.

For .Net Web forms (I am assuming web, since you didn't say thick or web client) which is not MVC, it was a nightmare maintaining them. Web Forms applications that lived more that a couple years tended to become big balls of mud. Even then developers discovered ways to use MVC with web forms.

Ironically, the lack of MVC architecture in ASP.NET web forms was one of the driving complaints that lead to the development of ASP.Net MVC framework.

From experience if you don't use some MVCesk approach, your solutions become hard to maintain and bloated. These applications will die a slow painful death.

If your solutions are small one-off projects, the by all means throw something together. Heck there are tools that will generate everything from the screens to the data access layer. Whatever works to get the job done.

查看更多
Fickle 薄情
3楼-- · 2019-03-31 21:12

Classic CRUD apps built using tools like VB6 and Delphi have user interfaces, persistent storage and don't use MVC. Most of them used data aware controls linked directly to database fields

查看更多
【Aperson】
4楼-- · 2019-03-31 21:14

Couple of links comparing various MV* patterns which might be useful:WPF patterns : MVC, MVP or MVVM or…? & MVC, MVP and MVVM

查看更多
淡お忘
5楼-- · 2019-03-31 21:29

User interface is View and an application will always have a model and the bridge between the two is Controller. The whole MVC is nothing special as this is how the things will be always.

At the most you can get rid of Controller and have your view talk to your model but you loose the flexibility.

查看更多
对你真心纯属浪费
6楼-- · 2019-03-31 21:31

In theory :

MVC is a proved technology and yada-yada-yada, and it is ideal for websites.

But in a real case:

A serious project that use MVC required a framework, hence you are following a framework with all their limiting and restrictions. So, at this point, the specific implementation of MVC is rule and not a simple "guideline".

Also MVC fail miserably for websites when it is about to connect to the model other than simple POST/GET, it fail with xml asynchronism and it fail with ajax. (*)

(*) exist some patch but a design must be clear and functional and if you need to "patch it" then it is neither clear nor functional.

Personally i think that the main problem with MVC is that it put so much effort in the Controller, where most project use not more that 5 lines for the controller part.

ps: Most "well done" MVC projects are 3-tier project.

ps2: MVC excluding some framework, is just a buzzterm, IS NOT A SERIOUS TERMINOLOGY and it is reflexed in the group of "interpretation of mvc".

查看更多
虎瘦雄心在
7楼-- · 2019-03-31 21:32

I've developed an alternative to ASP.NET MVC. You get the same loose coupling and separation of concerns but the difference is in how you go about building your projects.

I have a couple of videos on my blog, source code for the framework, a sample project and a few VS.NET add-ins (New Project item, New Builder and New View).

Builder for ASP.NET

Some key differentiating Features are 1. Templates are just html - no code mixed with templates 2. Templates are thus reusable across views and Web site designers can design templates in their design tool of choice 3. Strongly typed code (no ViewData and stuff) so you get intillisense, compile time checking, F12 navigation etc. 4. You build pages as compositions of views rather than an inside-out approach 5. View can be treated as "real" classes. 6. Everything is complied so no run-time compilation

Quite a few other differentiating factors as well.

查看更多
登录 后发表回答