Introduction: Can be used as an example of Visual Studio .Net, DuWamish must contain some information that Microsoft .NET design team wants to convey to developers, in fact, Duwamish is indeed known as a classic. Net developer learning classic Examples, whether it is from its design architecture, programming skills, or code style, there should be a standard .NET enterprise application should have characteristics. Therefore, by studying the example of duwamish, the master can understand the design idea of the .NET application architecture, and the low hand can learn the programming skills of .NET, it is really old. ^ _ ^ However, more purposes of this article are for intermediate .NET learners, such readers are often familiar with C # or vb.net syntax, will use some basic class libraries and have some smaller program of. But when they started to develop a real-level application that truly practical value, there is a feeling of indulgence. If you are in such a learner, please follow me in the world of Duwamish, I believe you will gain. -------------------------------------------------- ------------------------------ Duwamish Introduction: Microsoft companies always launch some public sources accordingly The application example of the code will illustrate the characteristics of the new technique, and developers can also achieve new technologies through the code of this example to achieve the purpose of implementation. Microsoft demonstrates the most popular e-commerce companies in typical online shopping practices to customers (B2C) patterns, including member qualifications, accounts for online shopping practices, including membership, accounts Basic features such as management, shopping carts, search and checkout processes. Duwamish has experienced three versions 4.0, 5.0, and 7.0, each version of the release of technology progress, and each version represents the most advanced technology trend at the time. It will be to study and discuss the highest version of DUWAMISH, experienced COM / COM technology and DUWAMISH of the Microsoft DNA architecture, which is completely .NET technology and architecture in the latest version, more advanced and mature than before. If you have a Visual Studio .NET, you can find and install it in your vs.net Enterprise Samples directory, for example: c: / program files / microsoft visual studio .NET / Enterprise Samples /, or you can also Go to http://astradigital.com/duwamish7vb/ This address looks at its presentation instance in the Internet. Other details of Duwamish, please refer to the MSDN help included with Visual Studio .Net, address is: ms-help: //ms.vscc/ms.msdnvs.2052/dwamish7/html/vtoriduwamishbooks70.htm, no more details here. -------------------------------------------------- ------------------------------ Duwamish structure analysis: DUWAMISH 7.0 is a typical N-layer architecture that is divided into four Logic layer: The Web layer web layer provides access to the app for the client. This layer is implemented as a Web project in the duwamish.sln solution file. The Web layer consists of an ASP.NET web form and code hidden file.
The web form is just a user operation with HTML, and the code hidden file implements event processing of various controls. Business appearance layer business appearance layer provides processing accounts, category browsing, and books for web layers. This layer is implemented as the BusinessFacade project in the duwamish.sln solution file. The business appearance layer is used as an isolation layer that isolates the user interface to the implementation of various business functions. In addition to the low-level systems and support functions, all calls to the database server are made through this assembly. The Business Rule Layer Business Rule layer is implemented as the BusinessRules project in the duwamish.sln solution file, which contains various business rules and logic implementations. Business rules complete this task such as the verification of customer accounts and book orders. Data Access Layer Data Access Layer provides data services for business rules layers. This layer is implemented as a DataAccess project in the duwamish.sln solution file. More confusing is the business appearance layer and business rule layer. Many people have listened to the three-layer structure when learning the N-layer structure. It is: representation of layers, intermediate layers, and data layers. Duwamish's Web and data access layers are better understood, that is, the representation layer and data layer in the traditional sense, then what is the connection between business appearance layers and business rules and our familiar intermediate? -------------------------------------------------- ------------------------------ Design ideas: In the web application, some operations are just simple from the database according to the conditional extraction Data, do not need to be processed, and display data directly on the web, such as querying a list of books. Other operations, such as calculating the total price of books in the order and calculating a rebate according to customer level, etc., this part often has many different functions, and it is more complicated. We can imagine it first. If we use a three-layer structure, these business logic will generally be placed in the middle layer, then the internal and large varieties of the internal, and the use of different types of calling tasks are all completely settled. Indicates the layer. This will increase the amount of code that represents the layer, complicates the task of the layer, and the indication layer is only responsible for accepting the user's input and the task of returning the result is not commensurate, and increasing the degree of coupling between the layers and layers. In order to solve this problem, let's first look at the description of the FACADE mode in the "Design Mode": Intent: Provide a consistent interface for a set of interfaces in the subsystem, the FACADE mode defines a high-level interface, this interface makes this One son is easier to use. Applicability: When you want to provide a simple interface for a complex subsystem. Subsystems tend to become more complicated because of continuous evolution. Most mode uses more smaller classes. This makes the subsystem more reusability, and it is more easier to customize the subsystem, but this also brings some difficulties to those users who do not need to customize subsystems. FACADE provides a simple default view that is enough for most users, and those users who need more customizable can cross the FACADE layer. There is a lot of dependence between the client program and the abstract class. Introducing FACADE to separate this subsystem from customers, and other subsystems, can increase the independence and portability of the subsystem. When you need to build a subsystem of a hierarchy, use the FACADE mode to define the entry points in the subsystem. If the subsystem is interdependent, you can make them communications with FACADE, which simplifies the dependence between them.
Structure Figure: This contradiction, justice, justice and design mode, the problem that needs to be solved in the Facade mode is very consistent, the solution proposed in "Design Mode" is to introduce a FACADE object, let this façade are responsible for Manage the call to the internal class of the system and provide a single and simple interface for the representation layer. This façade object, in our duwamish design, is the businessfacade layer. The following is the structural relationship of duwamish: We can clearly see from the figure, the browser first calls the representation layer web, and then the web will send the request to the business appearance layer, the business appearance layer is preliminary, and whether it is determined if You need to call the business rules layer or directly call the data access layer to obtain data. Finally, the data access layer accesses the database and returns the result to the browser in accordance with the procedure (for other structural modules, respectively).
-------------------------------------------------- ---------------------------- Code example: The following is a code example of two different processing paths: Get Product Directory Repayment appearance service layer: productSystem = new ProductSystem (); categorySet = productSystem.GetCategories (categoryID); exterior layer directly call the business data layer: public CategoryData GetCategories (int categoryId) {if (dsCommand == null) {throw new System.ObjectDisposedException ( . GetType () FullName);} return FillCategoryData ( "GetCategories", "@CategoryId", categoryId);} Add call the business layer order represented facade layer: public void AddOrder () {ApplicationAssert.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 orderrsystem ()); addorder (CartorderData);} business appearance layer calling business rule layer: public orderdata addorder (OrderData Order) {Applicatio nAssert.CheckCondition (! order = null, "Order is required", ApplicationAssert.LineNumber); (new BusinessRules.Order ()) InsertOrder (order); return order;} business rule layer calls the data layer:. public bool InsertOrder (OrderData ORDER) {// 省 省 省 省 (isvalid) {Using (DataAccess.OrDERSDERSDATAACCESS = New DataAccess.Iders ()) {Return (Order)> 0;}} else returnaf false } ------------------------------------- ------------------------------ Summary: Through the analysis of Duwamish7, we master Façade mode,