"Anatomy PetShop" Series VI: the presentation layer design of PetShop

Source: Internet
Author: User

The presentation layer (presentation Layer) design can give the system customer the most direct experience and the most complete confidence. Just like the acquaintance of people, it is always difficult to forget the first meeting. A product that is delivered to the customer, if the user interface (users Interface,ui) on the lack of attractive features, interface unfriendly, not considerate, even if this product performance is very excellent, reasonable architecture, business logic to meet the needs of customers, but still difficult to get customers favor. The saying goes: "Buddha wants gold, people want clothes", especially for Web applications, Web pages are like people's clothing, representing the whole system's identity and face, is to attract "customers" the biggest selling point.

"Shortcoming than Zang", as a arty lack of me, do not intend to make a fuss on the user interface of the art design, is a book omitted to mention. This chapter focuses on the design of the presentation layer, or in the context of architectural design, describes the application of the pattern in the presentation layer design, ASP. NET control design and application, but also includes the introduction of the new features of ASP.net 2.0.

6.1 MVC pattern

The most important pattern in the presentation layer design is the MVC (Model-view-controller, model-View-controller) pattern. The MVC pattern was first proposed by the Smalltalk language research group and is widely used in user interaction applications. Controller according to user request (Response) modify the properties of model, at this time event is triggered, all dependent on Model View object will automatically update, and based on the model object to generate a response (Response) information, Return to controller. Martin Fowler, in the enterprise Application architecture model, shows the entire process of applying the MVC pattern, as shown in Figure 6-1:

Figure 6-1 The typical MVC pattern

If you split the MVC pattern into three separate parts: model, View, Controller, we can implement and manage the relationships between them by Gof design patterns. In the architecture design, the domain object of business logic layer and data value object of data access layer belong to model object of MVC pattern. If you want to manage the relationship between model and view, you can use the Observer mode, view as the Observer, once the model's property values change, will inform the view based on the value of the model update. Controller, as an object that controls user requests/responses, can take advantage of the mediator model, which is specifically responsible for tuning between request/response tasks. And for view itself, on the basis of the idea of component design, we usually design it as a component or a control, which, depending on its own characteristics, together form an object structure similar to a recursive combination, so we can design the view object using the composite pattern.

However in. NET platform, we do not need to implement the MVC pattern ourselves. For the View object, ASP. NET already provides a common Web control, we can also customize the user control by inheriting System.Web.UI.UserControl, and use the ASPX page to combine WEB controls to implement the view. Asp. NET defines the System.Web.UI.Page class, which corresponds to the controller object of the MVC pattern and can handle the user's request. The use of codebehind technology, so that the user interface display and UI implementation logic completely separate, that is to say, view objects and controller objects become relatively independent of the two parts, thus conducive to the reuse of code. Compared to the ASP, this programming approach is more consistent with the programmer's programming habits, while it is beneficial to the division and collaboration between developers and UI designers. As for the model object, it is the domain object of the business logic layer. Moreover,. NET platform provides a DataSet object through ado.net to facilitate binding with the Web control's data source.

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.