ASP.NET MVC - separating large app

后端 未结 5 733
天涯浪人
天涯浪人 2020-12-14 04:10

I\'ve been puzzled by what I consider a contradiction in terms: ASP.NET MVC claims to be furthering and supporting the \"separation of concern\" motto, which I find a great

5条回答
  •  没有蜡笔的小新
    2020-12-14 04:56

    Separating code into separate assemblies is orthogonal to separation of concerns. Where the code lives is not a "concern". Separation of concerns has to do with responsibilities and direction of dependencies of various components. For example, Views are responsible for rendering the output, and the controller knows about the views, but the views don't really have intimate knowledge of the controller.

    Likewile, Models don't know anything about either views or controllers, but both views and controllers will know about the model.

    However, back to your question. As jfar points out, moving controllers and models into another assembly is trivially easy and will work. Moving views into another assembly is trickier. Embedded resources with a custom virtual path provider is one way, but not one we generally recommend for a high performance site. But if it meets your needs, go for it.

提交回复
热议问题