What is an MVC framework and why is it necessary/u

2019-03-10 06:10发布

I know that an MVC framework allows you to separate business logic, data base access and presentation, but why do we need a framework to do this.

Can't we just keep our classes separated, perhaps using different packages/folders for the model, view and controller classes?

9条回答
SAY GOODBYE
2楼-- · 2019-03-10 06:46

You are correct, there are strategies that you can implement to help with separation of concerns without using MVC.

Microsoft's ASP.NET MVC framework is one strategy that can be employed, and that is what I think you are asking about. This MVC framework makes such separation of concerns easy.

The other major advantage of MVC is testability - (depends on whether you believe in unit testing - I do).
The MVC framework ensures that all orchestration logic is on your controllers and through the FormControls collection allows full unit testing of all aspects of your application except for how it is presented.

As the MS MVC framework encourages adherence to common rules and structure of the application which should lead to greater maintainability.

The major downside of MVC is the code-in-front code weaving required for presentation, but this can be easily overcome.

查看更多
太酷不给撩
3楼-- · 2019-03-10 06:49

Hai Friends There are somemany types of architecture frame work has been there,firstly i know 2tier and 3 tier frame work ,the 3 tier and mvc ,entity framework are same but in different name's,so study a good background in any one architecture there fore if you went to any multinational companies ,you can easly score/highlight to your carrer.

Model View Controller or MVC as it is popularly called, is a software design
pattern for developing web applications. A Model View Controller pattern is made 
up of the following three parts:

**Model** - The lowest level of the pattern which is responsible for maintaining data.

**View** - This is responsible for displaying all or a portion of the data to the user.

**Controller** - Software Code that controls the interactions between the Model and View
查看更多
Explosion°爆炸
4楼-- · 2019-03-10 06:59

In my opinion the thing you are talking about is the MVC pattern and not a specific framework. Of course you can go and keep all your classes within one project and still use the MVC pattern, as you have all your UI code in the views, the logic in the controllers, ...

A MVC framework on the other hand makes it easier for you to use this pattern. It may provide some base classes for controllers and a mechanism for the communication between view and controller.

I don't know if you are familiar with ASP.NET MVC. The framework itself is very small, but it helps you developing an application with the MVC pattern, as you don't have do think about the previously decribed areas...

Hope this helps

查看更多
欢心
5楼-- · 2019-03-10 07:00

MVC stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner than the traditional ASP.NET web development. Web applications developed with ASP.NET MVC are even more SEO (Search Engine) friendly. Developing ASP.NET MVC application requires Microsoft .NET Framework 3.5 or higher.

Model:

  • MVC model is basically a C# or VB.NET class.
  • A model is accessible by both controller and view.
  • A model can be used to pass data from Controller to view.
  • A view can use model to display data in page.

View:

  • View is an ASPX page without having a code behind file.
  • All page specific HTML generation and formatting can be done inside view.
  • One can use Inline code (server tags ) to develop dynamic pages.
  • A request to view (ASPX page) can be made only from a controller’s action method

Controller:

  • Controller is basically a C# or VB.NET class which inherits system.mvc.controller.
  • Controller is a heart of the entire MVC architecture.
  • Inside Controller’s class action methods can be implemented which are responsible for responding to browser OR calling views.
  • Controller can access and use model class to pass data to views
  • Controller uses ViewData to pass any data to view.

MVC Basic Architecture

查看更多
爷的心禁止访问
6楼-- · 2019-03-10 07:01

You can of course approach it yourself by segregating your classes. A framework supplies common scaffolding that you wouldn't have to build yourself. But it will also impose some structure on your code. You'll have to evaluate whether the framework helps more than it hurts.

查看更多
forever°为你锁心
7楼-- · 2019-03-10 07:02

MVC is a code organization architecture style to organize your code-logic in a meaningful way for web applications. As a programmer I have almost puked when I have inherited other people's code when their code logic is all over the place and following their web application code turns into following a rabbit down the gutter hole. Why MVC? hmm.. well why should I use a filing cabinet or folders to organize my plethora of paper and not just have my papers stashed in a large pile and have others figure how they connect to each other. It increases code readability. With MVC it becomes very easy to follow code logic since you are following standard structure for a web application. Business logic is separated out from UI. Easier to delegate work decouple work on a project.

查看更多
登录 后发表回答