enterprise library building an application block n.
Skip this Video
Loading SlideShow in 5 Seconds..
Enterprise Library Building an Application Block PowerPoint Presentation
Download Presentation
Enterprise Library Building an Application Block

Loading in 2 Seconds...

play fullscreen
1 / 43

Enterprise Library Building an Application Block - PowerPoint PPT Presentation

  • Uploaded on

Enterprise Library Building an Application Block. Ed Jezierski Solution Architect Scott Densmore Software Engineer Ron Jacobs Product Manager. Architectural Guidance from patterns & practices Application Blocks Enterprise Library Vision Enterprise Library Application Blocks Configuration

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Enterprise Library Building an Application Block' - dotty

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
enterprise library building an application block

Enterprise LibraryBuilding an Application Block

Ed Jezierski

Solution ArchitectScott Densmore

Software Engineer

Ron JacobsProduct Manager

Architectural Guidance from patterns & practices

Application Blocks

Enterprise Library Vision

Enterprise Library Application Blocks



Data Access




Logging & Instrumentation

Exception Handling


patterns practices architecture guidance for the enterprise








patterns & practicesArchitecture Guidance for the Enterprise

ProvenBased on field experience

Authoritative Offer the best advice availableAccurateTechnically validated and testedActionableProvide the steps to success RelevantAddress real-world problems based on customer scenarios

Available online: http://www.microsoft.com/practices

Books available: http://www.amazon.com/practices


Application Blocks

Reference Architectures

Atomic solutions to recurring problems

Sub-system-level guidance for common services

System-level guidance for common customer scenarios
















Guidance for broad horizontal topics such as security, performance, deployment and operations

sound familiar
Sound familiar?
  • Having similar code pasted throughout your applications
  • Writing components to enable and encourage reuse…then rewriting them to meet specific application needs
  • Having components that should work well together, but…
  • Each component mandating inconsistent requirements on the consuming application
  • Longing for a way to future-proof your software library
enterprise library philosophy
Enterprise Library Philosophy
  • Consistency
    • Apply consistent design patterns and implementation approaches
  • Extensibility
    • Include extensibility points allowing developers to customize the behavior of the blocks by plugging in their own code or customize by directly modifying source code
  • Ease of Use
    • Leverage a graphical configuration tool
    • Provide a simpler installation procedure
    • Include clear and complete documentation and samples
  • Integration
    • Application blocks should be designed to work well together and tested to make sure that they do. But it should also be possible to use the application blocks individually
enterprise library v1
Enterprise Library v1














enterprise library vision

Customer Y library

Partner X library


Enterprise Library

Customer Z library

Enterprise Library Vision

p&p blocks

Partner blocks

Customer blocks

Block Specification

Community blocks

elements of an application block
Elements of an Application Block
  • Core functionality
  • Pluggable providers
  • Factories
  • Configuration
  • Unit tests
  • Quick Starts
  • Guidance and reference documentation
core functionality
Core Functionality
  • Central to its operation
  • May be influenced via configuration settings, but basic behavior cannot be changed without source code modifications
  • Often internal, but when exposed to an application, it is typically provided via a single class, interface, or facade
  • It’s OK to have core functionality – not everything must be replaceable or even configurable!
core functionality examples
Core Functionality Examples
  • Caching
    • Cache implementation (hashtable) – not exposed
    • Scavenging algorithm –not exposed
    • Cache manager – exposed as a class
  • Exception Handling
    • Exception policy – exposed as a class with single public static method (HandleException)
  • Logging and Instrumentation
    • Log filters – not exposed
pluggable providers
Pluggable Providers
  • Associated with an application block capability, defined by a “provider type.”
    • Caching: Backingstore
    • Data Access: Database
    • Exception Handling: Exception Handler
  • A provider is a specific implementation of a provider type. Each application block includes at least one provider implementation of each provider type
    • Caching: Database and isolated storage backingstores
    • Data Access: SQL, DB2 and Oracle databases
pluggable providers1
Pluggable Providers
  • Decouples the application block's core functionality from specific implementation, achieving the following goals
    • Variability
    • Extensibility
    • Encapsulation
    • Portability across environments
    • Minimized coupling between application blocks
  • Specified in configuration data with type information and a name
provider implementations and configuration
Provider Implementations and Configuration
  • Providers typically allow for configuration of each specific implementation
  • Example: the replace exception handler has a configuration setting for the new exception type
  • The abstract base class ConfigurationProvider defines the contract for initializing a provider with configuration information
  • Decision point: create a new provider implementation, or configuration property of an existing implementation
provider factories
Provider Factories
  • Uses Plugin [Fowler] pattern to create providers
  • Neither applications nor application blocks require information about specific implementation of provider
  • Specific implementation to be constructed determined by configuration settings
  • Abstract base class (ProviderFactory) in Configuration Application Block contains code to instantiate configurable providers
provider factories1
Provider Factories
  • Static method to create provider objects
  • Allow for creation of default provider (as specified by configuration settings)
  • Allow for creation of named provider
  • ' Create the default database instance
  • Dim db As Database = DatabaseFactory.CreateDatabase()
  • ' Use a named instance to map to configuration
  • Dim salesDb As Database = DatabaseFactory.CreateDatabase("Sales")

Allows you to reconfigure and execute the application without recompiling

  • Allows you to easily adapt the application block to meet the needs of different enterprise scenarios
  • Creation and editing of configuration settings is done with the Configuration Console
  • Configuration settings may be defined for an application block’s core functionality and for each provider type
  • Using configuration settings to adapt an application block to a particular situation has two advantages:
    • Characteristics of an application block can be configured by different people at different times in the application life cycle
    • The application block can be incrementally adapted for increasingly complex situations
  • Runtime configuration
    • Object graphs that represent configuration settings
    • Configuration Application Block reads settings from storage and returns objects to application block
    • XML File Storage Provider and Transformer require that objects be serializable
  • Design-time configuration
    • Allow settings to be displayed, changed and validated using the Configuration Console
design time configuration
Design-Time Configuration
  • Based upon System.ComponentModel
    • Configuration node is of type Component
    • The Configuration Console provides the Site
    • Services are available through Config Block
  • Configuration node classes for each node in the configuration tree
  • Each node determines the properties to be displayed when node is selected
  • Validation rules can be included for any property
configuration nodes
Configuration Nodes
  • Determine how the Configuration Console displays the hierarchy of configuration nodes
  • Determine which/how properties are exposed in the graphical interface
  • Enable the Configuration Console to validate that the values a user assigns to an application block's properties are appropriate
  • Can contain references that point from one application block to another (such as an authorization database that points to a database instance)
  • Contain references to the runtime data classes
configuration design manager
Configuration Design Manager
  • Implements IConfigurationDesignManager interface
  • Allows an application block to be added to an application’s configuration hierarchy
  • Creates menu items and commands that are invoked as user interacts with the Configuration Console to configure the application block
  • Responsible for loading and saving configuration data
  • Assembly must be located in same directory as Configuration Console executable
configuration application block support
Configuration Application Block Support

The Configuration Application Block provides much of the plumbing for runtime and design-time configuration

configuration console
Configuration Console


Configuration Nodes

Validation Error

unit tests
Unit Tests
  • Verify functionality of application block
  • Verify that modifications to application block have not cause regression
  • Enterprise Library developed using Test Driven Development (TDD)
quick starts
Quick Starts
  • Demonstrate common scenarios of application block usage
  • Display output indicating what happened “under the covers”
  • Detect common errors (e.g. user didn’t perform required setup) and display useful information
  • Goal: Open solution, hit F5, and see it run
  • Integrated into Visual Studio
  • Guidance
    • Introduction and goals
    • Developing applications using the application block
    • Design of the application block
    • Extending the application block
    • Deploying the application block
    • Quick start walkthroughs
  • Reference API
    • Public and protected
    • Summaries, parameters and return values
a simple example hello world application block
A Simple Example: Hello World Application Block
  • Client application can use the application block to return a greeting for a specified user
  • The implementation of how the greetings are returned is encapsulated in a greeting provider
  • An application can use multiple greeting providers, each identified by a unique name
  • The Configuration Console is used to select the default greeting provider, used when the client does not specify a name for the provider
  • Each greeting provider has a default message, set by the Configuration Console
hello world application block core functionality
Hello World Application Block Core Functionality
  • Minimal to keep things simple
  • Includes the interface definition IGreetingProvider, which all greeting providers must implement
  • Includes the class HelloWorldConfigurationView
    • Derives from ConfigurationView
    • Exposes the runtime configuration settings required by the application block’s providers
    • Passed to the Initialize method of each provider when it is created
hello world application block configuration view
Hello World Application Block Configuration View
  • Initialized with ConfigurationContext
  • public virtual GreetingProviderData GetGreetingProviderData(string name)
  • {
  • // HelloWorldSettings is our runtime configuration object
  • HelloWorldSettings settings = GetHelloWorldSettings();
  • return settings.GreetingProviders[name];
  • }

Returns configuration data required by application block

  • public virtual string GetDefaultGreetingProviderDataName()
  • {
  • HelloWorldSettings settings = GetHelloWorldSettings();
  • return settings.DefaultGreeter;
  • }
hello world application block providers
Hello World Application Block Providers
  • Text greeting provider
    • Returns plain text greeting for specified user
    • Greeting for a user is determined by configuration settings
    • Includes configuration design-time support to allow greetings to be entered and validated
  • Custom greeting provider
    • Allows user to select the FQTN of a class that implements IGreetingProvider
    • Configuration is provided via a property bag of name-value pairs (no design-time support)
hello world application block runtime configuration
Hello World Application Block Runtime Configuration
  • Requirements
    • Block allows multiple greeting providers
    • Each greeting provider has a name
    • Text greeting provider can have multiple greetings
    • A greeting is name and a message
  • Configuration Information is represented as serializable classes
runtime configuration data
Runtime Configuration Data

<?xml version="1.0" encoding="utf-8"?>




Microsoft.Practices.Samples.HelloWorld, Version=, Culture=neutral,


<helloWorldSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultGreeter="Casual Greetings"



<greetingProvider xsi:type="TextGreetingProviderData" name="Casual Greetings" defaultGreeting="Hello World!">


<greeting name="John" message="Hi John." />

<greeting name="Maria" message="Ciao Maria!" />







runtime configuration classes
Runtime Configuration Classes
  • HelloWorldSettings
    • Includes configuration section name, collection of providers, and default greeting provider
  • GreetingProviderData (base class), TextGreetingProviderData, CustomGreetingProviderData
    • Common settings and settings specific to providers
  • TextGreetingDataCollection
    • Collection of text greetings
  • TextGreetingData
    • Name and message
runtime configuration class serialization
Runtime Configuration Class Serialization
  • Root object serialization
  • [XmlRoot("helloWorldSettings", Namespace=HelloWorldSettings.ConfigurationNamespace)]
  • public class HelloWorldSettings
  • {
  • }

Collection serialization

  • [XmlArray("greetings", Namespace=HelloWorldSettings.ConfigurationNamespace)]
  • [XmlArrayItem(Type=typeof(TextGreetingData), Namespace=HelloWorldSettings.ConfigurationNamespace)]
  • public TextGreetingDataCollection Greetings
  • {
  • get { return this.greetings; }
  • }
runtime configuration class serialization1
Runtime Configuration Class Serialization
  • XML include types for base classes
  • [XmlType("greetingProvider", Namespace=HelloWorldSettings.ConfigurationNamespace)]
  • [XmlInclude(typeof(CustomGreetingProviderData))]
  • [XmlInclude(typeof(TextGreetingProviderData))]
  • public abstract class GreetingProviderData : ProviderData
  • {
  • }
hello world design time configuration
Hello World Design-Time Configuration
  • Required to allow the application block to be configured with the Configuration Console
hello world client
Hello World Client
  • Create provider
  • // Create default greeting provider (determined by configuration)
  • IGreetingProvider defaultProvider = GreetingFactory.GetGreetingProvider();
  • // Create named instance
  • IGreetingProvider formalProvider = GreetingFactory.GetGreetingProvider("Formal Greetings");

Call provider methods

  • string greeting = defaultProvider.SayGreeting(“John”);
additional resources
Additional Resources
  • Improving Web Application Security


  • Improving .NET Application Performance and Scalability


  • Application Architecture for .NET


  • PatternShare.org
  • Enterprise Library Communityhttp://go.microsoft.com/fwlink/?linkid=39209&clcid=0x09
  • www.ronjacobs.com
    • Slides
    • Tech Tips
    • Podcasts
announcing enterprise library 1 0

Announcing: Enterprise Library 1.0

Download it Today!


patterns and practices live
Patterns and Practices Live!
  • Slides, Hands On Labs, On Demand Webcasts
  • Upcoming Live Webcasts
    • 3/28 Building your own block
    • 3/31 Enterprise Library Applied
    • 4/12 Global Bank Baseline Architecture
    • 4/14 Updater Application Block v2