5 min read

Introducing Enterprise Library

Enterprise Library (EntLib) is a collection of reusable software components or application blocks designed to assist software developers with common enterprise development challenges. Each application block addresses a specific cross-cutting concern and provides highly configurable features, which results in higher developer productivity. EntLib is implemented and provided by Microsoft patterns & practices group, a dedicated team of professionals who work on solving these cross-cutting concerns with active participation from the developer community. This is an open source project and thus freely available under the Microsoft Public License (Ms-PL) at the CodePlex open source community site (http://entlib.codeplex.com), basically granting us a royalty-free copyright license to reproduce its contribution, build derivative works, and distribute them.

More information can be found at the Enterprise Library community site http://www.codeplex.com/entlib.

Enterprise Library consists of nine application blocks; two are concerned with wiring up stuff together and the remaining seven are functional application blocks. The following is the complete list of application blocks; these are briefly discussed in the next sections.

  • Wiring Blocks
    • Unity Dependency Injection
    • Policy Injection Application Block
  • Functional Blocks
    • Data Access Application Block
    • Logging Application Block
    • Exception Handling Application Block
    • Caching Application Block
    • Validation Application Block
    • Security Application Block
    • Cryptography Application Block

Wiring Application Blocks

Wiring blocks provide mechanisms to build highly flexible, loosely coupled, and maintainable systems. These blocks are mainly about wiring or plugging together different functionalities. The following two blocks fall under this category:

  • Unity Dependency Injection
  • Policy Injection Application Block

Unity Application Block

The Unity Application Block is a lightweight, flexible, and extensible dependency injection container that supports interception and various injection mechanisms such as constructor, property, and method call injection. The Unity Block is a standalone open source project, which can be leveraged in our application. This block allows us to develop loosely coupled, maintainable, and testable applications. Enterprise Library leverages this block for wiring the configured objects. More information on the Unity block is available at http://unity.codeplex.com.

Policy Injection Application Block

The Policy Injection Application Block is included in this release of Enterprise Library for backwards compatibility and policy injection is implemented using the Unity interception mechanism. This block provides a mechanism to change object behavior by inserting code between the client and the target object without modifying the code of the target object.

Functional Application Blocks

Enterprise Library consists of the following functional application blocks, which can be used individually or can be grouped together to address a specific cross-cutting concern.

  • Data Access Application Block
  • Logging Application Block
  • Exception Handling Application Block
  • Caching Application Block
  • Validation Application Block
  • Security Application Block
  • Cryptography Application Block

Data Access Application Block

Developing an application that stores/ retrieve data in/from some kind of a relational database is quite common; this involves performing CRUD (Create, Read, Update, Delete) operations on the database by executing T-SQL or stored procedure commands. But we often end up writing the plumbing code over and over again to perform these operations: plumbing code such as creating a connection object, opening and closing a connection, parameter caching, and so on.

The following are the key benefits of the Data Access block:

  • The Data Access Application Block (DAAB) abstracts developers from the underlying database technology by providing a common interface to perform database operations.
  • DAAB also takes care of the ordinary tasks like creating a connection object, opening and closing a connection, parameter caching, and so on.
  • It helps in bringing consistency to the application and allows changing of database type by modifying the configuration.

Logging Application Block

Logging is an essential activity, which is required to understand what’s happening behind the scene while the application is running. This is especially helpful in identifying issues and tracing the source of the problem without debugging. The Logging Application Block provides a very simple, flexible, standard, and consistent way to log messages. Administrators have the power to change the log destination (file, database, e-mail, and so on), modify message format, decide on which category is turned on/off, and so on.

Exception Handling Application Block

Handling exceptions appropriately and allowing the user to either continue or exit gracefully is essential for any application to avoid user frustration. The Exception Handling Application Block adapts the policy-driven approach to allow developers/administrators to define how to handle exceptions.

The following are the key benefits of the Exception Handling Block:

  • It provides the ability to log exception messages using the Logging Application Block.
  • It provides a mechanism to replace the original exception with another exception, which prevents disclosure of sensitive information.
  • It provides mechanism to wrap the original exception inside another exception to maintain the contextual information.

Caching Application Block

Caching in general is a good practice for data that has a long life span; caching is recommended if the possibility of data being changed at the source is low and the change doesn’t have significant impact on the application. The Caching Application Block allows us to cache data locally in our application; it also gives us the flexibility to cache the data in-memory, in a database or in an isolated storage.

Validation Application Block

The Validation Application Block (VAB) provides various mechanisms to validate user inputs. As a rule of thumb always assume user input is not valid unless proven to be valid. The Validation block allows us to perform validation in three different ways; we can use configuration, attributes, or code to provide validation rules. Additionally it also includes adapters specifically targeting ASP.NET, Windows Forms, and Windows Communication Foundation (WCF).

Security Application Block

The Security Application Block simplifies authorization based on rules and provides caching of the user’s authorization and authentication data. Authorization can be done against Microsoft Active Directory Service, Authorization Manager (AzMan) , Active Directory Application Mode (ADAM), and Custom Authorization Provider. Decoupling of the authorization code from the authorization provider allows administrators to change the provider in the configuration without changing the code.

Cryptography Application Block

The Cryptography Application Block provides a common API to perform basic cryptography operations without inclining towards any specific cryptography provider and the provider is configurable. Using this application block we can perform encryption/decryption, hashing, & validate whether the hash matches some text.

LEAVE A REPLY

Please enter your comment!
Please enter your name here