.NET Framework design pattern and practice

zhaozj2021-02-16  54

The design pattern has always been a popular topic. During the .NET Framework learning process, we can find a large number of design patterns, this topic focuses on two aspects: 1. Revecil design mode in .NET Framework 2. Practice in the design pattern in the .NET application.

Welcome everyone to actively participate, show new discovery and experience of your learning process and shared with the same portions. Here is the Model-View-Controller (MVC) mode in ASP.NET:

Everyone knows that the web page initially shows static content, with the rapid changes in demand, then there is a large number of web design of dynamic content. In ASP.NET, you can write the content and logical control code to be displayed in an ASPX file like the past ASP, we call this design as a single page design, which is usually for small applications. Say it is good, but if the page content display logic is complicated, or if you want to update the page display mode, this mixing code and content is difficult to maintain and expand. Code-Behind and MVC: The purpose of the MVC design mode is to provide a solution of separation view (display), model (MODEL, data content), controller (Controller) solution, making the content of the content And the content itself is divided, and the benefits are obvious. First of all: Different developers can focus on their own tasks, such as interface designers can be responsible for page design parts; programming staff can only be responsible for data. The code-behind in ASP.NET is this design mode: *. ASPX is part of the View, *. Aspx. (Cs / vb ..) is a model section, then where are you may ask if the controller? Then I can tell you that the Page object you inherit is a Controller. In the ASP.NET's default implementation, the Page object plays a controller role, which is responsible for receiving the user's behavior, and notifying View in an event. Model makes the corresponding operation, as if you have seen the Controller in ASP.NET is not very obvious. Here is the relationship between MVC design patterns: -----------------------

By reading this article, I found that Event and Delegate in .NET are actually the application of the OBServer design mode, Event is equivalent to the subject object, while Delegate acts as a viewer. If you are familiar with the OBServer mode, you will find what their Solution is similar. Conversely, if you understand the work mechanism of Event and Delegate, you will understand the OBServer design mode. So what is the benefit of using the OBSERVER design pattern? In fact, when I explained Event and Delegate were OBSERVER design patterns, this problem was already excessive. The MVC is generated on the JSP. JSP has a mechanism to support it. There are some new features on ASP.NET, which can have new methods.

Borrow MVC, even this is to understand the asp.net.aspx is View, which inherits from .ASPX.CS generates client page code at runtime. .aspx.cs is Controller, which obtains the user's input according to the _viewstate returned by .aspx, including the event, call the relevant code, and returns the result. .asmx, .cs is Model even prefer to release the business logic layer and data layer of the processing to class, web services, and transotiet.

转载请注明原文地址:https://www.9cbs.com/read-17970.html

New Post(0)