Ideal Design Mode for E-Commerce - CMP

xiaoxiao2021-03-06  71

Ideal Design Mode for E-Commerce - CMP

Author: abin Time: 2004.10.10 Source:

http://blog.9cbs.net/abinstudio

E-commerce sites often require high flexibility, because e-commerce websites face picky customers, is the forefront of sales. The traditional component-based design mode is a bit awkward when designing an e-commerce website, and each database data structure has to lead to a new compilation of the underlying component. In order to avoid this shortcomings, I Will use (Container-Managed Persistence hosted container-type persistence), that is, CMP said in EJB.

I don't use Java, but from some of the information I read, Java implementation CMP is easier than .NET is easy, and puts forward such design patterns earlier. From a general overall situation, CMP is also troublesome than traditional hosting components, but once the maintenance of future e-commerce websites will be greatly flexible.

CMP is a design pattern: all data operations are not unresolved in crud (create, retrieve, update, delete), and CMP maps cruded into an XML file (I will use Web.config as it in the later design This mapping includes all database fields, field data types, CRUD operation names, stored procedure names (I will use SQL Server to develop this e-commerce website, and all stored procedures). Below is a piece of mapping:

CARTCONTENTS // Map unique identity

CartContents

// crUd command mapping

WebShop_delete_shoppingcart // Stored Procedure Name Mapping

CARTID // Database field name mapping

@cartid // Stored Procedure Parameter Map

varchar // data type

Input // data operation direction (corresponding to the storage process)

50 // Data Size

......

......

......

After mapping, the database field changes, it is not necessary to change the parameters in the component, because the component is read from the web.config, as long as the map corresponding to the web.config file can be changed, no need to re-need Compile components. Since the crud command is also mapped, the CMP data operation does not even need to understand the data access method, and how the business logic is not contact with the data access layer.

Summarize, use CMP benefits: First, database changes do not need to recompile the data operation layer, this is the most direct embodiment, and it is best to understand. Second, since the data operation is encapsulated in CMP, the business object data access has not contacted, so it can be convenient to use a variety of data sources, such as XML, Access, SQL Server, Web Services. Third, I have written some database operating layers you often use to perform stored procedures, so as long as you write some changes, you can use it slightly, you can use it from new compilation. If you use CMP, you will not Need to be compiled, because the data definition is defined in web.config, you can use it directly according to the corresponding format change.

Disadvantages: The development process is complicated relative to the managed component, and is applied in the Web Application, and the Windows program is applied less.

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

New Post(0)