Application Architecture Guide - Chapter 12 - Data Access Layer Guidelines

From Guidance Share

(Difference between revisions)
Jump to: navigation, search
Revision as of 19:17, 29 December 2009 (edit)
JD (Talk | contribs)

← Previous diff
Revision as of 19:18, 29 December 2009 (edit)
JD (Talk | contribs)

Next diff →
Line 60: Line 60:
-#<b>Create an overall design for your data access layer: </b>+* <b>Step 1. Create an overall design for your data access layer: </b>
*Identify your data source requirements. *Identify your data source requirements.
Line 72: Line 72:
*Determine strategies for handling data source errors. *Determine strategies for handling data source errors.
-#<b>Design your data access components</b>: +<b>Step 2. Design your data access components</b>:
*Enumerate the data sources that you will access. *Enumerate the data sources that you will access.
Line 82: Line 82:
*Determine relevant design patterns. For example, consider using the Table Data Gateway, Query Object, Repository, and other patterns. *Determine relevant design patterns. For example, consider using the Table Data Gateway, Query Object, Repository, and other patterns.
-#<b>Design your data helper components:</b> +<b>Step 3. Design your data helper components:</b>
*Identify functionality that could be moved out of the data access components and centralized for reuse. *Identify functionality that could be moved out of the data access components and centralized for reuse.
Line 94: Line 94:
*Consider the setup and implementation of logging for your helper components. *Consider the setup and implementation of logging for your helper components.
-#<b>Design your service agents:</b> +<b>Step 4. Design your service agents:</b>
*Use the appropriate tool to add a service reference. This will generate a proxy and the data classes that represent the data contract from the service. *Use the appropriate tool to add a service reference. This will generate a proxy and the data classes that represent the data contract from the service.
*Determine how the service will be used in your application. For most applications, you should use an abstraction layer between the business layer and the data access layer, which will provide a consistent interface regardless of the data source. For smaller applications, the business layer, or even the presentation layer, may access the service agent directly. *Determine how the service will be used in your application. For most applications, you should use an abstraction layer between the business layer and the data access layer, which will provide a consistent interface regardless of the data source. For smaller applications, the business layer, or even the presentation layer, may access the service agent directly.

Revision as of 19:18, 29 December 2009

Contents

Chapter 12: Data Access Layer Guidelines

Objectives

  • Understand how the data layer fits into the application architecture.
  • Understand the components of the data layer.
  • Learn the steps for designing these components.
  • Learn the common issues faced when designing the data layer.
  • Learn the key guidelines for designing the data layer.
  • Learn the key patterns and technology considerations for designing the data access layer.

Overview

This chapter describes the key guidelines for designing the data layer of an application. The guidelines are organized by category and cover the common issues encountered, and mistakes commonly made, when designing the data layer. Figure 1. shows how the data layer fits into typical application architecture.






Figure 1 A typical application showing the data layer and the components it may contain


Data Layer Components

  • Data access logic components. Data access components abstract the logic necessary to access your underlying data stores. Doing so centralizes the data access functionality, which makes the application easier to configure and maintain.


  • Data helpers / utilities. Helper functions and utilities assist in data manipulation, data transformation, and data access within the layer. They consist of specialized libraries and/or custom routines especially designed to maximize data access performance and reduce the development requirements of the logic components and the service agent parts of the layer.


  • Service agents. When a business component must use functionality exposed by an external service, you might need to create code that manages the semantics of communicating with that service. Service agents isolate your application from the idiosyncrasies of calling diverse services, and can provide additional services such as basic mapping between the format of the data exposed by the service and the format your application requires.



Approach

A correct approach to designing the data layer will reduce development time and assist in maintenance of the data layer after the application is deployed. This section briefly outlines an effective design approach for the data layer. Perform the following key activities in each of these areas when designing your data layer:


  • Step 1. Create an overall design for your data access layer:
  • Identify your data source requirements.
  • Determine your data access approach.
  • Choose how to map data structures to the data source.
  • Determine how to connect to the data source.
  • Determine strategies for handling data source errors.

Step 2. Design your data access components:

  • Enumerate the data sources that you will access.
  • Decide on the method of access for each data source.
  • Determine whether helper components are required or desirable to simplify data access component development and maintenance.
  • Determine relevant design patterns. For example, consider using the Table Data Gateway, Query Object, Repository, and other patterns.

Step 3. Design your data helper components:

  • Identify functionality that could be moved out of the data access components and centralized for reuse.
  • Research available helper component libraries.
  • Consider custom helper components for common problems such as connection strings, data source authentication, monitoring, and exception processing.
  • Consider implementing routines for data access monitoring and testing in your helper components.
  • Consider the setup and implementation of logging for your helper components.

Step 4. Design your service agents:

  • Use the appropriate tool to add a service reference. This will generate a proxy and the data classes that represent the data contract from the service.
  • Determine how the service will be used in your application. For most applications, you should use an abstraction layer between the business layer and the data access layer, which will provide a consistent interface regardless of the data source. For smaller applications, the business layer, or even the presentation layer, may access the service agent directly.
Personal tools