"Data Access Mode" note: Data Accessor

xiaoxiao2021-03-06  117

Chapter 1: Data Accessor (Data Accessor) Mode

Brief description

"Encapsate the physical data access details in a single component, only public logic operations. Application code reserves the knowledge of the underlying data mode, but only separates with data access."

Package principle

o Public logic operation, encapsulation physical operation -, for example, using a SQL statement directly using the SQL statement.

o Public logic resources, encapsulate physical resources - make full use of resources, such as connectivity.

o Package platform detail - platform irrelevant.

o Pack Optimization Details - Place the optimized elasticity in the data accessor, not the application code, so that it can be uniformly optimized.

applicability

o requires the complexity and platform issues of physical data access to application logic.

o Semantic positions provided by the underlying physical database driver requires management additional semantics. For example, the lock mechanism of the application level.

o Need to define multiple data access implementations and choose from during runtime.

advantage

o Clear Application Code - Application code that is full of data access details is difficult to read and maintain, use the data accessor to make the application code more set to its own business logic.

o New database features or platforms - If the data access code is distributed throughout the system, if you want to use the new database characteristics (such as switching from the SQL Server platform to the Oracle platform), you will browse and modify the code of the entire system, and use Data Accessors can encapsulate this detail into a component.

o Combined Optimization Strategy - When adjusting the application performance, data access code is often the primary analysis focus. The same use data accessor can be used to introduce an optimization policy to the entire system.

o Exchangeable physical data access implementation.

Disadvantage

o Limits the application of the application to data access - requesting the data accessor design to have sufficient versatility.

Strategy

o Define universal logical operations - on the one hand, pay attention to versatility; do not introduce unnecessary complexity in the other hand, can solve this problem by research cases. I feel that the accumulation of experience is also very important.

o Leave Optimization and Improved Location - The function is often sacrificed during the development process to ensure progress.

o Prevents the application of the application from offset.

Instantiate

o SingleTon Data Accessor Implementation.

o Initialization and parameter transfer - Dampoints are required to define an additional parameter in the constructor and operation of the class.

o Data Accessor Factory.

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

New Post(0)