Take advantage of Microsoft's Application Blocks for .NET

In an effort to make life easier for developers, Microsoft has started to publish information on patterns and practices. These Application Blocks for .NET include source code and sample applications. Take advantage of these helpful tools and get a head start on your next project.

Like every developer and architect out there, you want your solutions to be efficient, robust, elegant, and cost effective. But as you well know, attaining these goals isn't always easy. Throw into the mix the fact that you’re working with a fairly new set of technologies, namely the Windows .NET Framework and Visual Studio .NET, and your task becomes even more difficult. However, all is not lost. In the last year Microsoft has begun the process of making your life easier by publishing information on patterns and practices, some of which you’ll find enlightening and useful.

Patterns and practices
Since the late 1990s there has been an increased awareness within Microsoft that its customers require guidance in using the quickly growing array of technology emanating from Redmond. Among the first efforts were a series of Prescriptive Architecture Guides (PAGs) that detailed how to use Microsoft technology to create an Internet data center (IDC) and enterprise data center (EDC). These, however, were aimed at the infrastructure of an organization and not so much at developing solutions on those architectures.

Since that time Microsoft has expanded the notion and created a Patterns & Practices group that serves application architects and developers, IT professionals, and information workers. This group now publishes its information on its own Web site as well as on the .NET Architecture Center. In addition, the group publishes the content in book form orderable through the same site.

The Patterns & Practices group publishes four types of information:
  • Patterns—Patterns are reusable solutions that address specific architecture, design and implementation scenarios. These are documented by the group in papers on the Web site (for example 32 developer patterns are explicated). Each of these patterns also has an associated community for discussion.
  • Reference Architectures—Reference architectures are IT system-level architectures like the IDC and EDC mentioned above.
  • Reference Building Blocks and IT Services—These include reusable subsystem designs that address common technical situations. The Application Blocks discussed in the remainder of this article are examples of Reference Building Blocks.
  • Lifecycle Practices—These include guidance for tasks that fall outside architecture and design, for example, deployment and operational management.

Additional Information
A complete list of the patterns and practices can be found at the Patterns & Practices Web site.

Reference Building Blocks
As I mentioned, the Patterns & Practices group publishes Reference Building Blocks to address common technical scenarios. As of this writing they have published eight of these building blocks for developers called Application Blocks for .NET. Typically, each application block includes the complete source code for the subsystem in both C# and VB, and sample applications called QuickStarts to get you started.

In the Table A below, I address each of the blocks to help you get a feel for how and why it can be used.
Table A
Name Date Published What? Why?
Data Access Application Block Release 1.0 April 2002, Release 2.0, June 2003 Implements a data access helper component, SqlHelper, which helps execute statements against SQL Server 7.0 and higher by exposing a set of static methods and reduces the amount of data access code you have to write. V2.0 supports the .NET Framework v1.1. Use it if you are using SQL Server as the database and wish to reduce the amount of data access code you write. Can use it internally in your own data access classes. Versions of SqlHelper for OleDb and Oracle written in C# are included in the Nile 3.0 sample application.
Exception Management Application Block April 2002 Provides a simple and flexible mechanism for publishing exception information through an ExceptionManager class. Also supports filtering and creating your own exception publishers to publish data to sources other than files and event logs using text and XML. Also provides a BaseApplicationException class from which to derive, which collects additional environmental information. Use it as the basis for your exception handling framework. Ideal for applications that use exception chaining or wrapping and pass exceptions up the call stack. Custom publishers can be used to log exception information to shared databases.
Aggregation Application Block June 2003 A component that dispatches Service Agents to collect information from various sources for the application. The application then makes requests to the aggregate component and it returns a single XML document of the collected data. It uses the Exception Management Block and can be used with both the Asynchronous Block and the Caching Block. Use it when your application needs to bring together data from various sources and those sources may change over time. The Aggregation Block serves to abstract the underlying data sources.
Asynchronous Invocation Application Block June 2003 A component that dispatches requests on background threads and then notifies the application when complete. It uses the Exception Management and Data blocks. This block is meant to be used with the Aggregate Block and can work with the Caching block. Use it when the data sources your application communicates with may require a lengthy call. Using the Async Block makes it appear as if the application is more responsive by allowing Web pages to be built incrementally.
Caching Application Block June 2003 Allows applications to make requests of a CacheManager object that either returns the data or invokes a Service Agent to retrieve it. Allows items to be expired from cache and cached data to be stored in a variety of format including SQL Server, memory mapped files, or a Singleton object. It uses both the Exception Management and Data Blocks. Can also be used with the Async and Aggregation blocks. Use it when you need to cache data in Windows Forms or other non-Web based applications. ASP.NET provides its own cache and so would not typically be required for Web applications. Very useful for improving performance.
Configuration Management Application Block June 2003 A component that abstracts the location of configuration information used in an application and adds features including encryption, caching, and extensibility. It also adds the ability to both read and write the configuration data. Use it when your application might require its configuration data to be stored in different locations at different times. Also take advantage of it for encrypting sensitive information.
Updater Application Block June 2003 A component that can be used to download new versions of applications to client machines (using BITS for example). Includes a manifest to specify all the related files and ensure the entire application is downloaded. Provides optional file verification and support for custom downloading and verification components. It uses the Exception Management Block. Use it when your application needs to auto-update with new assemblies or when you are writing a service to provide client machines with updates to a variety of applications.
User Interface Process Application Block June 2003 A base class (ControllerBase) and User Interface Process Manager component that allow you to separate the logic and state of a user process from the UI needed to collect data and navigate. Includes a set of persistence managers that allow you to save the state of the process in SQL Server, an ASP.NET session, or a custom store. Use it when you need to implement the same process in different types of applications (Windows Forms, Web forms) or want to allow users to resume a session at a later time. Also ideal for wizard-based applications.
Reference Building Blocks

Start exploring
In these first eight application blocks, Microsoft has published a good deal of reusable code that you should start exploring and using where you can. And be sure to bookmark the patterns and practices site so you’ll be aware of new blocks as they become available.

Editor's Picks

Free Newsletters, In your Inbox