views:

110

answers:

2

We are compiling a list of common functions and methods into a utilities assembly. Part of this utilities assembly is to provide a façade over the Enterprise Library Logging Block. The utility assembly abstraction provides an extension over the Logging Block in a number of ways:

  • A custom database logging component to capture richer logging information in a RDBMS
  • Integrate the use of CorrelationManager with a primary focus on Web application sessions and request correlations
  • Integrated policy injection.

My question is; is it generally considered best practice to wrap 3rd party controls (like the Enterprise Library) up in a façade as described above?

+6  A: 

Yes. We use lots of EntLib components and wrap all of them. They are not really meant to be exposed to all the layers of your application. In the case you mention with the logging block, it's perfectly reasonable to establish a facade that wraps the call to the logging factory (we pass a custom configuaration file for each block for example) and then expose a much more simple interface to your callers (Logger.Log( ... ) for example). Another example is the data application block is almost always wrapped in a formal data access layer.

JP Alioto
Agreed -- improves isolation and facilitates testing via mocks.
Jay
+1  A: 

Yes. Where I work we always wrap our 3rd party libraries (especially open source ones) in a facade pattern. The reason that we do this is to ensure future component updates do not break our system.

zacbarton