Archive

Posts Tagged ‘AOP’

Castle DynamicProxy Tutorial

July 2nd, 2009 stiiifff No comments

A while ago, Krzysztof Koźmic started a blog post series about Castle Project‘s DynamicProxy (DP2).

If you wanna know what the heck are:

  • Proxies with & without target
  • Interceptors
  • Interceptor selectors

Go read his amazing tutorial. I’m sure you’ll learn something ;)

If needed, have  a quick refresh on AOP : here, there & there.

And if you get inspired by DP2 and the Castle Project in general, follow the evolution & suggest new ideas !

MEF Preview 5 – Recomposition, POCO & Custom Type Systems

April 28th, 2009 stiiifff 3 comments

Go & take the time to read those posts about the latest drop (preview 5) of MEF (Managed Extensibility Framework):

All of this will come for free as part of .Net 4.0 … isn’t that cool or what? :)

Categories: MEF Tags: , , ,

Dependency Injection is Dead ? Not so sure about that

July 2nd, 2008 stiiifff No comments

Simon Ice has an interesting, although a bit provocative, post on his blog entitled Dependency Injection is Dead.

He's exposing a way to do Dependency Injection using AOP, which is a novel approach but probably has severe limitations in the long run, in terms of predicability & capability compared to what we can expect from good IoC Containers. Read the answers of Nate Kohari and Ayende Rahien, who know what they are talking about. ;)

Categories: Patterns Tags: , ,

CircuitBreaker Interceptor

June 12th, 2008 stiiifff 1 comment

An interesting pattern discussed in Release It!, Design and Deploy Production-Ready Software, is the CircuitBreaker pattern. I was thinking about implementing it in C# but well, as often, someone took care of it already (thus less work for me). :)

Tim Ross has a first post on his blog where he describes the CircuitBreaker and his implementation. In the second part, he introduces several improvements such as a ServiceLevel variable and the possibility to ignore certain exception types.

Although a very nice implementation, I wasn't thinking about a class for my CircuitBreaker implementation … but about an Interceptor.

Indeed, when designing a system built of loosely-coupled components using an IoC container, you will often add interceptors at strategic places (integration points with external systems) to catch failures, log statistics, … So, it makes sense to make the CircuitBreaker an interceptor that can be applied to those critical parts of your application in order to fail-fast in the event of repeated failures & relieve the external system that is under stress.

Here a quick implementation of Tim's class as an interceptor (using Castle Windsor IoC container) … the test code is dumb, but I guess you'll get the point. ;)

CircuitBreakerInterceptor.rar

Note: Instead of porting the whole code into the Interceptor class, it's also possible to simply get a CircuitBreaker object injected by he container into the Interceptor (interceptors are just a special kind of components), and the Interceptor would delegate the invocation call to the CircuitBreaker.

Btw, for those who don’t know Castle Windsor container well yet (never too late to learn something), this small sample also demonstrate the ease of using & configuring the container (as well as creating interceptors).