Application Architecture Guide - Chapter 12 - Data Access Layer Guidelines

From Guidance Share

Revision as of 19:17, 29 December 2009; JD (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search


Chapter 12: Data Access Layer Guidelines


  • 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.


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.


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:

  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.
  1. 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.
  1. 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.
  1. 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