Core Functionality


An application block typically provides an implementation for solving a problem that is not solved by the .NET Framework or for which there is no alternate solution that is both simple to use and extensible for adaptability. Core functionalitycode that provides the base functionality that implements best practices for solving that particular problemmust exist for any application block. The core functionality for a block is the functionality that is not intended to be extended through providers, because it must be consistent independent of the functionality that any one provider offers.

For example, in the Caching Application Block, CacheManagers are not an extension point; they are exposed as a class but are not extensible. Additionally, cached data is always stored in an internal hashtable when it is read from a BackingStore or items are added to the cache at runtime. The hashtable is not exposed and another mechanism for caching this data is not provided as an extension point. All application blocks have core functionality that is fundamental to the solution that it is providing. When creating an application block, some thought must be given to what functionality should be core to the block and what should be "pluggable" and extensible.

Three major classes are used to provide the core functionality for the Data Mapping Application Block: DatabaseWrapper, DataCacheSettings, and DataMapper. The DatabaseWrapper acts as a service layer that encapsulates the Data Access Application Block. This service layer primarily takes advantage of the Data Access Application Block's support for retrieving typed DataSets and propagating the changes in those DataSets to the backend database. It has the additional benefit of respecting any complex relationships that may exist between the tables in the DataSet and allows the transaction level to be set through configuration so an update can occur in the scope of a transaction.

The DataCacheSettings class contains information about how a particular typed DataSet should be cached after it is obtained via the DatabaseWrapper. Lastly, the DataMapper class is an abstract base class that subscribes to the best practice for exposing expected functionality that is common across all data access logic components. The best practice states that such functionality should be exposed in a separately defined interface or base class. This class uses both the DataCacheSettings and DatabaseWrapper to obtain typed DataSets, cache them, set transactions for them, and propagate the changes made to them back to the data store. The DataMapper is designed to make it easy to develop business data access logic components that contain functionality for managing "entities" through Create, Retrieve, Update, and Delete operations.

Figure 9.1 shows the primary classes that provide this core functionality. These classes are not exposed as extension points; that is, other classes cannot be plugged in to provide different implementations. For example, the DatabaseWrapper cannot be replaced by another class that retrieves and updates data from a data source in a way that is different from the methods used in the DatabaseWrapper. To do so would require modification of the code base provided with the application block. You can find more information about the specific features and design of these classes in Appendix A.

Figure 9.1. Classes Representing Core Functionality for the Data Mapping Application Block





Fenster Effective Use of Microsoft Enterprise Library(c) Building Blocks for Creating Enterprise Applications and Services 2006
Effective Use of Microsoft Enterprise Library: Building Blocks for Creating Enterprise Applications and Services
ISBN: 0321334213
EAN: 2147483647
Year: 2004
Pages: 103
Authors: Len Fenster

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net