Duwamish in-depth analysis-structure

Source: Internet
Author: User
Duwamish in-depth analysis-structure

Abstract: This paper introduces in detail the structure framework of Duwamish online e-bookstore routine, and analyzes in detail some features and design patterns of this structure. Directory: Introduction Duwamish introduces the structure analysis design idea code example summary introduction: can be used as Visual Studio. net. Duwamish must include Microsoft. the Net design team wants to send some information to developers. In fact, Duwamish can indeed be called. A classic example of Net developer learning, whether from its design architecture, programming skills or code style, shows us a standard. net Enterprise applications should have characteristics. Therefore, by studying Duwamish examples, the experts can understand the design idea of. Net application architecture, and the low-handed can learn. Net programming skills, which is really suitable for all ages. :) However, the purpose of this article is more for intermediate. net learners. These readers are often familiar with C # Or VB. NET syntax, some basic class libraries will be used, and some small programs will be made. However, when they started to develop an enterprise-level application with real practical value, they had a feeling of nowhere to start. If you happen to belong to this kind of learners, please follow me into the Duwamish world and I believe you will surely get the harvest. Duwamish Introduction: Every time Microsoft launches a new technology, it will always launch some examples of open source code to illustrate the characteristics of the new technology, developers can quickly master the new technology and implement it by studying the code of this example. Microsoft creates a virtual online sales system application for an e-commerce company that sells books online, demonstrate to users the most common e-commerce enterprise-to-customer (B2C) model in typical online shopping practices, it includes basic functions such as membership, account management, shopping cart, search and checkout process. Duwamish has gone through three versions: 4.0, 5.0, and 7.0. The release of each version confirms the technological progress. Each version represents the most advanced technology trend at that time. The most recent Duwamish version 7.0 will be studied and discussed here. It has gone through the COM/COM + technology and the Duwamish of Microsoft DNA architecture, and is fully used in the latest version. net technology and architecture, more advanced and mature than before.

If you have installed Visual Studio. net, you can.. Net Enterprise Samples Directory, such as: C: \ Program Files \ Microsoft Visual Studio. NET \ Enterprise Samples \, or you can go to http://astradigital.com/duwamis#vb/to view a demo of the workshop in internet. For more information about Duwamish, see Visual Studio. net with the MSDN help address: ms-help: // MS. VSCC/MS. MSDNVS.2052/dwamish7/html/vtoriDuwamishBooks70.htm. Duwamish Structure Analysis: Duwamish 7.0 is a typical N-layer architecture. Its structure is divided into four logic layers: The Web layer provides clients with access to applications. This layer is implemented as a Web project in the Duwamish. sln solution file. The Web layer consists of ASP. NET Web forms and hidden code files. Web forms only use HTML to provide user operations, while code hidden files implement event processing for various controls. The business appearance layer provides the Web layer with an interface for processing accounts, category browsing, and book purchases. This layer is implemented as the BusinessFacade project in the Duwamish. sln solution file. The business appearance layer is used as the isolation layer, which isolates the user interface from the implementation of various business functions. Except for low-level systems and support functions, all calls to the database server are performed through this assembly. The business rule layer is implemented as the BusinessRules project in the Duwamish. sln solution file. It contains the implementation of various business rules and logic. Business Rules complete tasks such as verifying customer accounts and book orders. The data access layer provides data services for the business rule layer. This layer is implemented as the DataAccess project in the Duwamish. sln solution file. What is confusing is the business appearance layer and business rule layer. Many people hear the most about the layer-3 structure when learning the layer-N structure development, which is the presentation layer, middle Layer and data layer. Duwamish's WEB layer and data access layer are easy to understand, that is, the traditional presentation layer and data layer, what is the relationship between the business appearance layer and the business rule layer and the intermediate layer that we are familiar? Design Philosophy: In Web applications, some operations simply extract data from the database based on conditions, without any processing, and directly display the data to the Web page, for example, you can query a list of books of a certain type. Other operations, such as calculating the total price of books in an order and calculating kickbacks based on the customer's level, usually have many different functional classes and the operations are complicated. We can first imagine that if we adopt a three-tier structure, these commercial logic will generally be placed in the middle layer, then there will be a wide variety of internal, the Calling tasks of different classes with different usage methods are completely implemented in the presentation layer. This will inevitably increase the amount of code in the presentation layer, complicate the tasks in the presentation layer, and is not commensurate with the tasks in which the presentation layer only accepts user input and returns results, it also increases the coupling between layers. To solve this problem, let's take a look at the description of the Facade mode in design patterns: intent: provide a consistent interface for a group of interfaces in the subsystem, the Facade mode defines a high-level interface, which makes this subsystem easier to use. Applicability: When you want to provide a simple interface for a complex subsystem. Subsystems tend to become more and more complex as they evolve. In most modes, More and smaller classes are generated. This makes subsystems more reusable and easier to customize, but it also brings some difficulties for users who do not need to customize subsystems. Facade can provide a simple default view, which is sufficient for most users, and users who need more customization can bypass the Facade layer. There is a large dependency between the implementation part of the client program and the abstract class. Introducing Facade to separate this subsystem from customers and other subsystems can improve the independence and portability of the subsystem. When you need to build a layered sub-system, use the Facade mode to define the entry points for each layer of the sub-system. If subsystems are mutually dependent, you can make them communicate only through Facade, thus simplifying the dependency between them. Structure:

The contradiction mentioned above is exactly the same as the problem to be solved in the Facade mode described in the design mode. The solution proposed in the design mode is to introduce a Facade object, let this Fa & ccedil; ade be responsible for managing class calls within the system, and provide a single and simple interface for the presentation layer. This Fa & ccedil; ade object is the BusinessFacade layer in our Duwamish design. The following is the Duwamish structure diagram:

We can clearly see that the browser first calls the presentation layer WEB, then the WEB sends the request to the business appearance layer, and the Business appearance layer initially processes the request, determine whether to call the business rule layer or directly call the data access layer to obtain data. Finally, access the database at the data access layer and return the results to the browser according to the following steps (other structure modules involved in the figure will be described in detail later ). Sample Code: The following shows two sample codes for different processing paths: Obtain the product directory. The presentation layer calls the business appearance layer: productSystem = new ProductSystem (); categorySet = productSystem. getCategories (categoryID); the Business appearance layer directly calls the data layer: public CategoryData GetCategories (int categoryId) {if (dsCommand = null) {throw new System. objectDisposedException (GetType (). fullName);} return FillCategoryData ("GetCategories", "@ CategoryId", categoryId);} Add the order presentation layer to call the business appearance layer: public void AddOrder () {PplicationAssert. CheckCondition (cartOrderData! = Null, "Order requires data", ApplicationAssert. lineNumber); ApplicationLog. writeTrace ("Duwamish7.Web. cart. addOrder: \ r \ nCustomerId: "+ cartOrderData. tables [OrderData. CUSTOMER_TABLE]. rows [0] [OrderData. PKID_FIELD]. toString (); cartOrderData = (new OrderSystem ()). addOrder (cartOrderData);} Business appearance layer call business rule layer: public OrderData AddOrder (OrderData order) {ApplicationAssert. checkCondition (order! = Null, "Order is required", ApplicationAssert. lineNumber); (new BusinessRules. order ()). insertOrder (order); return order;} business rule layer call data layer: public bool InsertOrder (OrderData order) {// complex processing logic is omitted here if (isValid) {using (DataAccess. orders ordersDataAccess = new DataAccess. orders () {return (ordersDataAccess. insertOrderDetail (order)> 0 ;}} else return false ;}summary: by analyzing the structure design of Duwamish7, we have mastered the Fa & ccedil; ade mode, I learned how to improve the application structure through the Fa & ccedil; ade mode, and learned the basic concepts and processing procedures of Duwamish7, it lays a foundation for further analysis and study of other parts of Duwamish7.

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.