The MVC Pattern
Model-View-Controller (MVC) has been an important architectural pattern in computer science for many years. Originally named Thing-Model-View-Editor in 1979, it was later simplified to Model-View-Controller. It is a powerful and elegant means of separating concerns within an application (for example, separating data access logic from display logic) and applies itself extremely well to web applications. Its explicit separation of concerns does add a small amount of extra complexity to an application’s design, but the extraordinary benefits outweigh the extra effort. It has been used in dozens of frameworks since its introduction. You’ll find MVC in Java and C++, on Mac and on Windows, and inside literally dozens of frameworks.
- The Model: A set of classes that describes the data you’re working with as well as the business rules for how the data can be changed and manipulated
- The View: Defines how the application’s UI will be displayed
- The Controller: A set of classes that handles communication from the user, overall application flow, and application-specific logic
MVC as Applied to Web Frameworks
The MVC pattern is used frequently in web programming. With ASP.NET MVC, it’s translated roughly as:
- Models: These are the classes that represent the domain you are interested in. These domain objects often encapsulate data stored in a database as well as code that manipulates the data and enforces domain-specific business logic. With ASP.NET MVC, this is most likely a Data Access Layer of some kind, using a tool like Entity Framework or NHibernate combined with custom code containing domain-specific logic.
- View: This is a template to dynamically generate HTML.
- Controller: This is a special class that manages the relationship between the View and the Model. It responds to user input, talks to the Model, and decides which view to render (if any). In ASP.NET MVC, this class is conventionally denoted by the suffix Controller
- Enables the full control over the rendered HTML.
- Provides clean separation of concerns(SoC)
- Enables Test Driven Development (TDD).
- Following the design of stateless nature of the web.
- The .NET runtime is a very mature, well-understood framework that remains very popular.
- RESTful URLs that enable SEO.
- No ViewState and PostBack events
- The platform is highly extensible. Parts of the framework can be easily replaced as necessary in order to provide enhanced functionality.
- Microsoft has continued to strengthen the underlying platforms that The Official Microsoft ASP.NET Site MVC builds upon in Windows Server and SQL Server.
- MVC provides a good testing story.
MVC is a Framework for web development which is fully customizable.There are a lot of classes and methods in MVC, as in MVC we can replace any existing component with our custom implementation.
Methods, as used in MVC, are part of the controller class, called action methods are used to handle the requests. Usually, each request is handled by a separate action method. That being said, MVC.NET Framework is rather server side technology you can create a web application connect to databases and scale from there.