MVC是编写asp.net应用程序的最佳方式吗? [英] Is MVC the best way to code asp.net applications?

查看:76
本文介绍了MVC是编写asp.net应用程序的最佳方式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我知道没有一个最好的办法来做一切。对不起,没有说出来。在数据访问教程的上下文中,如果您必须执行该教程中所做的项目,那么您是否应该使用MVC,如果您必须选择其中一个,则可以使用它?



更新: MVC是编写asp.net应用程序的更合适的方法,而不是在这里找到的教程:



http://www.asp.net/Learn/data-access/



原始



我问,因为我初步了解了MVC与Java应用程序,然后像RoR和Django。这些其他项目和公司就像MVC已经存在了很长一段时间,从我发现的那样。然后,微软开始将MVC放入.net框架中。



我问,因为我不知道如何设计好的东西,并认为我做的很好,以模拟什么asp.net网站与Scott Mitchell的教程。我认为在BLL中创建抽象层是一直要走的路,直到我发现了MVC和现在的asp.net的MVC。



我真的不知道什么正确的方式是做事情。我只是创建了我需要的东西,但是我无法感觉到我缺少某些东西。



MVC是在大型项目中开始做事情的正确方法,具体来说意味着MVC和ASP.NET,但也可以意味着PHP和他们的MVC框架之一。



我想要解决一个标准的做事方式。 ..现在无论如何。



而且,出于好奇,为什么微软现在才开始做MVC?



更新: MVC是否比asp.net上的当前教程更好?



我是指Scott Mitchell教程,他创建抽象的BLL。或者是一个linq问题。我应该说,我明白需要保持逻辑和表现分开,但不确定最好的方法。我正在使用asp.net教程。工作正常然后,我发现世界其他地方,正如我看到的,正在使用MVC。然后微软开始开发MVC,所以对我来说,其他的方法似乎已经过时了,错误的做事方式。

解决方案

不,不是唯一最好的办法。



MVC只是一种设计模式。所有设计模式的目标是简单。所以只要它使你的设计更简单,就可以一起去吧。如果它使您的特定应用程序变得更加复杂,请尝试其他方法。



不幸的是,有些人认为,如果他们看到一个模式,他们应该使用它。这不是真的设计模式本质上不会使您的应用程序更好。他们不是结局。它们是一种手段(这是简单的)。所以你应该使用它们,只有当它们是值得的。



在我看来,没有一个很好的理由的过度架构的事情比编写没有任何具体设计的代码更糟糕。 / p>

编辑:关于ASP.NET MVC:我对ASP.NET Web表单有负面的个人偏见。在MVC之前,我通过编写自定义处理程序对HTML进行了细粒度的控制,从而大部分高级项目的动态方面。 Web窗体使Web开发变得非常简单,但它们特别有一些很好的东西,但有时候是有问题的。第一个是 ViewState ,第二个是复杂的 WebControl 架构。不要误会我这些都是ASP.NET的辉煌迹象。我还没有看到一个Web开发平台,就像ASP.NET Web Forms一样简单,这只是因为 WebControl 支持需要 ViewState 。但是,在某些项目中,您要对渲染的HTML进行精确控制(特别是当您有一些客户端逻辑时)。您还想在大型项目中使服务器端代码可维护。在这些领域,ASP.NET MVC真的亮相。但是我认为ASP.NET Web窗体将仍然是一个很好的技术,它更适用。毕竟,正如我在一般的设计模式中所说的那样,你应该仔细评估你的设计,看看哪个更适合你的需要。



具体来说,关于数据访问,MVC通常需要比Web Forms相应的代码更多的代码。为了呈现表格数据(即GridView适用),我认为ASP.NET Web窗体是更容易的完成任务的方法。然而,大多数数据驱动的Web应用程序不仅仅是直接在数据库中操纵表。他们有复杂的布局。 StackOverflow是一个很好的例子。当然数据驱动,但ASP.NET MVC更适合它。


update: I know there is no one best way to do everything. Sorry for not saying that right off. In the context of the data-access tutorials, if you had to do the project he did in that tutorial, would you do what he did or would use use MVC, if you had to choose one of them?

Update: Is MVC the more appropriate way to program asp.net applications, instead of the tutorials found here:

http://www.asp.net/Learn/data-access/

Original:

I ask, because I initially learned about MVC with Java applications, then things like RoR, and Django. These other projects and companies spoke as if MVC had been around for a very long time, and from what I found out it had. Then Microsoft started putting MVC into the .net framework.

I ask because I don't know how to design things very well and thought I was doing well to emulate what's on the asp.net site with Scott Mitchell's tutorial. I thought that creating abstract layers in a BLL was the way to go until I found out about MVC and now asp.net's MVC.

I honestly don't know what the "right" way is to do things. I just create what I need, but I can't help feel like I am missing something.

Is MVC the correct way to start doing things in large projects, specifically I mean MVC and ASP.NET, but could just as well mean PHP and one of their MVC frameworks.

I'd like to settle on a standard way of doing things...for now anyway.

And, out of curiosity, why did Microsoft only now start doing MVC?

UPDATE: Is MVC better than the current tutorial set on asp.net?

I'm referring to the Scott Mitchell tutorials where he creates the BLL for abstraction. Or is that a linq question as well. I should have said that I understand the need for keeping logic and presentation separate but unsure the best way to do it. I was using the asp.net tutorials. It worked fine. Then I found out the rest of the world, as I saw it anyway, was using MVC. Then Microsoft started developing MVC, so to me the other method seems obsolete and the wrong way to do things.

解决方案

No, it's not the only best way to do things.

MVC is just a design pattern. The goal of all design patterns is simplicity. So as long as it makes your design simpler, go with it. If it makes things more complex for your specific application, try a different approach.

Unfortunately, some people think if they see a pattern, they should use it. It's just not true. Design patterns don't inherently make your application better. They are not an end. They are a means to an end (which is simplicity). So you should use them only if they are worth it.

In my opinion, over-architecting things without a good reason is worse than writing code without any specific design.

EDIT: Regarding ASP.NET MVC: I have a negative personal bias toward ASP.NET Web forms. Before MVC, I did most of the dynamic aspects of advanced projects by writing custom handlers to have fine grained control over the HTML. Web Forms make Web development very easy but they have particularly a couple things that are good but sometimes are problematic. The first of which is ViewState and the second is complex WebControl architecture. Don't get me wrong. Those are signs of brilliance of ASP.NET. I haven't seen a single platform for Web development as easy as ASP.NET Web Forms and this is only because of great WebControl support which requires ViewState. However, in some projects, you want to have precise control on rendered HTML (specially when you have some client-side logic). You also want to make server side code maintainable in large projects. In those areas, ASP.NET MVC really shines. But I think ASP.NET Web Forms will remain a great technology where it's more applicable. After all, as I said regarding design patterns in general, you should carefully evaluate your design to see which one better fits your needs.

Specifically, about data access, MVC usually requires more code than Web Forms counterparts. For presenting tabular data (i.e where GridView is applicable), I think ASP.NET Web Forms is the easier way to accomplish things. However, most data driven Web apps are not just manipulating a table directly in a database. They have complex layout. StackOverflow is a great example of this. It is certainly data driven, but ASP.NET MVC better suits it.

这篇关于MVC是编写asp.net应用程序的最佳方式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆