And how nice, all of these things are out there ready to use – Microsoft Enterprise Library, Castle Windsor, log4net, Spring.NET, …
Except that I see too many examples (at work and other places) of developers not utilizing these goodies. And I hear some typical reasons:
- Don’t have time to look through the offerings and choose the right application block / application block framework
- Don’t have time to master the complex XML configuration needed to start using an application block
- Disagreements over choice of quite similar alternatives (especially with loggers and IoC containers)
- NIH! (Not Invented Here, so we roll our own)
I’m trying to meet these challenges by creating a framework called FirstBricks. FirstBricks is a thin wrapper-framework around existing application blocks. It has 4 core goals:
- Ease of use. You should be able to start using an application block with 2 lines of code and no config file mess. In other words it hides/encapsulates complex configuration until you really need (if ever).
- Abstractions. You don’t work against a specific application block implementation, you work against an abstraction. So for example, you log using an ILog, but you don’t need to care whether it is an EntLib logger, log4net or a test logger. And you can change the implementation any time using the dependency container.
- Extensibility. You should not need to modify the source if this framework. But you can extend it with your own application block implementations, configurators and even new abstractions. For example, this first version of FirstBricks has ist abstractions flavoured by the MS Enterprise Library as I know this best. If you don’t like that, you can create a new abstraction and still use the structure and consitency of the framework.
- Consistency. Every application block wrapping is done the same way, configuration is accessed the same way and so on.
Here is an example of FirstBricks in use. In this case we want to use just logging. To set things up:
// Tell FirstBricks to use the Enterprise Library implementations of it's application blocks. Bricks.Initialize<EntLibMappings>(); // Set up logging to a file Log.Configurator.ConfigureSimpleFileLog("AppLog.txt");
And to log, simply use a line like this anywhere in your application:
Log.Write("Something to log");
Take a look, try it out and don’t hesitate to give me feedback.
No comments:
Post a Comment