Block Building Made Easy

One of the coolest new capabilities we're building for Enterprise Library v3 is the Application Block Software Factory. As its name ever-so-subtly suggests, this will be a software factory for building your own application blocks. We'll be including an early drop of this factory in the first preview release of Enterprise Library v3 (soon, I promise!) - but in the meantime this blog is, as always, your best bet for some early details.

First, let me explain why we wanted to include a block factory in Enterprise Library. Right from the start, we built Enterprise Library with the expectation that people would want to extend it - either by building new providers, or by building entire new blocks. But while some types of extensibility are relatively straightforward for developers, things quickly get more and more complex if you want to do things like create strongly typed configuration classes, configuration design assemblies, or your own blocks with factories and provider hierarchies.

In EntLib v1 we included the "Hello World Application Block". While it wasn't hugely popular in enterprise applications (apparently people just aren't building applications that need to provide customized greetings :-), it did serve a useful purpose in providing simple examples showing the common patterns for building your own blocks. In v2 we didn't get time to update the Hello World Application Block, which was a shame as extending Enterprise Library actually got more complex as a result of the decoupling of blocks from configuration and the use of Object Builder. The source of all knowledge on building and extending v2 blocks is Brian's webcasts (here and here), but while the webcasts are a lot fun, it isn't necessarily the best format for helping you do the same.

In the meantime, we've started playing around with software factories, and we think this is a better way of demonstrating and automating routine but sometimes complex tasks when building a particular type of application (or application block, in this case). While the block factory in Enterprise Library won't be quite as in-depth as the standalone software factories, it does follow the same basic approach, and we're pretty excited about the potential for the factory to bring block- and extension-building to the masses.

So what does the factory let you do? This activity diagram shows the key stages to building a block or provider library, and the factory will include one or several recipes to help automate each step:

There are two basic scenarios supported by the factory: creating your own blocks, and creating your own provider libraries. Let's start with the provider library activities. A provider library is an assembly that contains providers for a block that lives somewhere else, for example you may want to create your own assembly with TraceListeners, Filters and Formatters that extend the Logging Application Block.

  • Create New Provider Library: This solution template will create an initial project structure for your provider library, including a runtime project, designtime project, unit test projects, and some common references and class files

  • Create New Untyped Provider for EntLib Block: This activity includes a number of recipes that make it very easy to build new providers for known Enterprise Library types, eg Logging TraceListeners, Exception Handlers, Caching Backing stores etc. The recipe will prompt for the name and generate a new class that includes all of the necessary interfaces and attributes. The untyped flavor of the recipes uses property bags for configuration, which eliminates the need to build your own configuration classes (runtime or designtime) but comes at the cost of type safety.

  • Create New Typed Provider for EntLib Block: This activity includes the same basic set of recipes as for the untyped providers, however they also generate a strongly-typed configuration class and wire this up to the provider. Just add configuration properties!

  • Convert Untyped Provider to Typed Provider: What if you created an untyped provider and later on you want to the plunge and make it strongly typed? Have we got a recipe for you!

  • Create Typed or Untyped Provider for Your Block: Of course you're not limited to building providers for EntLib blocks. But we'll discuss these activities in the context of building your own block (below).

  • Create Provider DesignTime: Once you have a strongly-typed provider, you probably don't feel like editing the XML by hand. The factory includes a recipe that will look at the runtime configuration class and generate some initial configuration design nodes. You'll want to spend some time cleaning it up by hand, for example to add icons, resources and validation, but the recipe does a lot of the dirty work for you.

Now on to building your own application block:

  • Create New Block: This will be a solution template that sets up an initial project structure for building your own block, including a runtime project, designtime project, unit test projects, and some common references and class files

  • Create New Provider Factory & Base: Most of our application blocks follow a similar pattern involving factories that can generate providers by name, where the actual type of the returned provider is defined in configuration (for example: Database db = DatabaseFactory.CreateDatabase("Sales"); may return an OracleDatabase class or a SqlDatabase class). This recipe sets up abstract base classes and interfaces for a new provider type, as well as a corresponding factory and its associated plumbing.

  • Create New Designtime Provider Base Node: This recipe takes a provider base type and generates the key design-time classes to support the complete hierarchy of that type of provider

  • Create Typed or Untyped Provider for Your Block: These recipes are much the same as the ones for the known EntLib provider types, except that you'll be prompted for more information such as the base classes and interfaces that correspond to your provider type

  • Convert Untyped Provider to Typed Provider: As above

  • Create Provider DesignTime: As above

Here's a screenshot showing how some of these recipes will turn up in a solution built with the Application Block template:

Of course, none of this is going to put developers or testers out of work - even with the factory you'll still need to write and test plenty of code. But we're hoping that the factory will make you more productive, make building blocks and providers accessible to more people, and will hopefully result in a lot of weird and wonderful new blocks in the community and in your organization.

As soon as the preview is available, I'll let you know...

Comments (26)
  1. "One of the coolest new capabilities in Enterprise Library v3 is the Application Block Software Factory

  2. Sounds great… I have a few ideas of some frameworks we use internally that can fit in an EntLib style app block.

    What’s the planned date for the first preview and the release?

  3. En la versión 3 de la Enterprise Library, vendrá incorporada una "software factory". Aunque todavía no

  4. El Bruno says:

    Buenas interesantes noticias de nuestros amigos de Patterns and Practices Block Building Made Easy Block

  5. El Bruno says:

    Buenas interesantes noticias de nuestros amigos de Patterns and Practices Block Building Made Easy Block

  6. David Hayden says:

    Will you be dogfooding the Application Block Software Factory to create a new block for Enterprise Library as a test to see if it really brings value and meets the needs of developers?

  7. Eric says:

    Will this one support Visual Basic?  Leaving the last software factory release without Visual Basic support has made my life a living hell.

    Thank you.

  8. David – That has definitely been our intent for the Validation Application Block. In reality we’ve been developing the block and the factory in parallel, so we’ve only been able to dogfood the factory as the relevant pieces come together. It’s likely the factory will get its best workout to help us build the design-time configuration for the balidation block.

    Eric – yes we plan to ship a version of the factory that generates VB code. However the most efficient way for us to develop is to work in one language throughout development, and then port it to another language right at the end. So the previews will be C# only, but we should have a VB version available at release.


  9. Ravi KP says:

    Hi Tom,

    Are you guys planning to release more documentation for object builder in this V3 version. Also i would like to know when i should go for software factory application block versus to ObjectBuilder.

    -Ravi KP

  10. msdn Austria says:

    Tom Hollander beschreibt auf seinem Blog detailiert, wie die neue Application Block Software Factory

  11. CoqBlog says:

    Et on continue les nouvelles concernant l’EntLib v3 par ce post de Tom Hollander qui expose une des fonctionnalités

  12. Anon says:

    Talk about desperate, this is all too confusing, never work in practice and yet another desperate attempt by the enterprise lib team.  

    I think a change of product manager would be appropriate at this time!

  13. Après une interruption momentanée de ma participation à la bloggosphère, je profite d’une accalmie passagère

  14. Application Block Software Factory

  15. Application Block Software Factory

  16. Yes, it’s finally here. The patterns & practices team is pleased to announce the official release

  17. neuhawk says:

    Enterprise Library 3.0 – April 2007 发布

  18. Bashmohandes says:

    Enterprise Library 3.0 Released

  19. The patterns & practices team has announced the official release of Enterprise Library 3.0 – April

  20. Loser-X says:

    Most excellent. I have looked at Enterprise Library in the past, but never quite found a suitable project

  21. Overview The patterns & practices Enterprise Library is a library of application blocks designed

  22. Despues de mucho esperaracion oficial del Enterprise Library 3.0 – April 2007 para.NET Framework 2.0 / 3.0. Punntos sobresalientes Si estuvieron tan atentos como yo los CTPs no habra muchas sorpres …

  23. EntLib 3.0 just dropped . Go get the bits here . For more details, see Tom Hollander’s most excellent

  24. TerryLee says:

    Tom Hollander今天在他的个人Blog中宣布,将会在下一个版本的Enterprise Library(开发代号为Enterprise Library v3)中提供一项非常酷的功能,就是Application Block Software Factory。 在之前两个版本的Enterprise Library中,我们也可以创建自己的Application Block,并且在Enterprise Library Jan2005中还提供了一个简单的自定义的Application Block的示例,但是对于开发人员来说,创建自己的Application

Comments are closed.

Skip to main content