An initial study of the ASP-MVC5 Learning Series MVC

Source: Internet
Author: User
Tags what is asp

Q1. What is MVC?
MVC is the abbreviation for Model-view-controller. It was introduced in 1970 as a software design model. The MVC pattern forces attention to separation-the domain model and the controller logic are loosely coupled with the UI. This makes it easier to maintain and test applications.

Q2. Explain the MVC design pattern?

MVC design pattern breaks down applications into 3 main parts: Model, view, controller (models, views, controllers)

Model-models represent a series of classes used to describe business logic, such as business models and data access operations, as well as data models. It also defines the business rules for how data is processed.

View-Views represent UI parts like CSS, jquery, HTML, and so on. Its primary responsibility is to demonstrate acceptance of data or models from the controller.

Controller-the Director is responsible for processing incoming requests. It accepts the user's input through the view, then processes the data model entered by the user, and finally renders the result to the user through the view. Generally speaking, the controller plays the role of Bridge (coordinator) between the view and the model.

Q3. What is domain driven design development?
Ans. Domain-driven Design (DDD) defines a series of guidelines and patterns that developers can use to develop a graceful system for different areas. DDD is neither a technology nor a set of methodologies. DDD mainly consists of the entity, Value Object, Aggregate, Service, repository five major parts.
Entity: An object with a unique flag, such as a user.
Value object: An object that does not have a unique flag, such as an enumeration. A value object can also be an entity depending on the situation.
Aggregate (aggregation): It realizes the cohesion of the domain model by defining the clear affiliation and boundary between objects, and avoids the formation of intricate and difficult-to-maintain object networks. Aggregations define a set of related objects that have cohesive relationships, and we think of aggregations as a unit of modified data. Domain Model: aggregation, aggregation Root explained.
Service (Service): services are used in applications to process business logic.
Repository (warehousing): The role of warehousing is the storage of data read, that is, encapsulating the data persistence framework. It does not care what database to use. Warehousing is not the data Access layer that we often say, but for security reasons, warehousing refers to a location for storage. The primary responsibility for warehousing is to handle aggregated and persistent related tasks (ADD, UPDATE, DELETE, GET).

MSDN Introduction to DDD

Q4. Explain the MVP model?

Ans. MVP is similar to MVC, except that the MVC controller is replaced with presenter. The MVP model breaks down the application into 3 main parts: Model, View, Presenter.

Model-models represent a series of classes used to describe business logic, such as business models and data access operations, as well as data models. It also defines the business rules for how data is processed.

View-Views represent UI parts like CSS, jquery, HTML, and so on. Its primary responsibility is to demonstrate acceptance of data or models from the controller.

Presenter-The responsibility is to handle UI behavior events on the view. Receives user input through view, then processes the user data through the model and then passes the results back to view. Do not want to completely decouple between view and Controller,view and presenter, it is through interface interaction. It also does not process and receive incoming requests.

MVP mode is typically used in ASP. NET Web form, Windows form application
Key points of the MVP model:

    1. The user interacts directly with the view.
    2. View and presenter are 1 to 1 relationships, one view corresponds to a presenter
    3. View and Model do not contact, are passed through Presenter.
    4. The communication between the parts is bidirectional.
    5. The view is very thin and does not deploy any business logic, called the "Passive View" (Passive view), without any initiative, and presenter is very thick, where all the logic is deployed.

Q5. Explain the MVVM pattern?

Ans. MVVM refers to the Model-view-view Model. MVVM supports bidirectional data binding between view and ViewModel. The state of the view model enables automatic propagation of changes to view. In general, ViewModel is the notification of ViewModel changes to the view through the Observer pattern.
Model-models represent a series of classes used to describe business logic, such as business models and data access operations, as well as data models. It also defines the business rules for how data is processed.

View-Views represent UI parts like CSS, jquery, HTML, and so on. Its primary responsibility is to demonstrate acceptance of data or models from the controller.

The duty of view Model-viewmodel is to expose methods, commands, and properties to maintain the state of the view, manipulate the Model as a result of view execution, and trigger events on the view itself.

Key points of the MVVM pattern:

    1. The user interacts directly with the view.
    2. View and ViewModel are 1-to-many relationships, and a view can correspond to multiple viewmodel.
    3. View saves a reference to ViewModel, but ViewModel is ignorant of the view.
    4. Data binding between view and ViewModel is bidirectional.

Angular is using this pattern.

Q6. What is ASP. NET MVC?
Ans. ASP is an open-source framework for developing Web applications based on the Microsoft. NET Framework. It ensures that the code is clean and tidy and focused on separation. The ASP. NET MVC framework has good extensibility and support customization.

Q7. How does the MVC pattern work under ASP?
Ans. We have one by one explanations in the order of model, View, controller:
The Model in ASP. NET MVC
The model in ASP. NET MVC can be decomposed into several different layers:

    1. Objects or ViewModel or Presentation layer-this layer contains simple objects or complex objects used for the presentation of a particular strongly typed view. These objects are used to pass data from a controller to a strongly typed view, and vice versa. The classes that correspond to these objects specify the validation rules that are defined by the data annotations. Typically, these classes have properties that you want to show to the corresponding view/page.
    2. Business Layer-is primarily used for the implementation of logic and data validation. Data is persisted to the database through the data Access Layer (DAL). This layer is called directly by the controller to process the user input and return the results to the view
    3. Data Access Layer-provides objects to access and manipulate the database. Typically, this layer uses some ORM frameworks such as EF, NHibernate.

The View in ASP.
View is the presentation of the data passed from the controller. It also assumes that the model is converted to display on the view's UI.
The Controller in ASP. NET MVC
Responds to an HTTP request and determines which specific action to handle according to the incoming request content. It receives user input through the view and then uses the model's help to process the user data and return the results to view.

Q9. What are the advantages of ASP. NET MVC versus Web Forms?
Ans. The main advantages are as follows:

        • Separation of concern (separation of concerns)-the MVC design pattern divides an ASP. NET MVC application into three parts, View, Controller, model. Easier to deal with procedural complexity issues.
        • TDD (test-driven development)-better support for test-driven development.
        • Extensible and pluggable (good Extensibility)-MVC supports pluggable, extensible. This makes it easier to replace and customize.
        • Full controls over application behaviour (complete control of the application)-MVC does not use view state and does not rely on server. Enables programmers to better control the behavior of the application while reducing the bandwidth to the server request.
        • ASP. Features is supported (strong ASP. NET feature Support)-The MVC framework is based on ASP, so you can use Asp.ent to include most features, such as authentication, authorization, permissions and role control, caching, session, and so on.
        • URL routing mechanism (routing mechanism)-The MVC framework provides a powerful URL routing mechanism so that we can build easy-to-understand and searchable URLs. This routing mechanism improves the accessibility of the application and facilitates search engine optimization.

Q11. What is the difference between a three-tier architecture and an MVC architecture?

Ans. Three-tier architecture is a linear architecture that includes: presentation layer, business logic layer, data access layer. The user interacts directly with the presentation layer.
The MVC architecture is a triangular architecture that divides an application into three parts, Model, View, Controller. The user interacts with the controller with the help of view.
MVC does not replace the three-tier architecture, and often the three-tier architecture is used together with MVC, which plays the presentation layer in the three-tier architecture.

Q12. What is the difference between ASP. NET WebForm and ASP.
Ans. The main differences are detailed in the following table:

Web Forms MVC
Event-Driven development model Lightweight MVC model-based development model
Service-side controls Html Helper
Status management technology (View State, Session) No automatic state management
File path-based routing Routing-based URLs
Follow Webfrom semantics Follow Razor engine semantics
View is tightly coupled with business logic (. aspx,. aspx.cs) Separation of view and business logic
Unified layout through master page (master pages) Unified layout Using Layout
Reuse via User Controls Reuse with partial view
With built-in data controls, easy to manipulate data Lightweight, provides comprehensive control tags and supports many features that allow rapid and agile development. Therefore, it is best to develop web interaction applications with the latest web standards.
Non-open source Open source

An initial study of the ASP-MVC5 Learning Series MVC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.