Aspects - I love it!

Posted by Marcus Hammarberg on November 19, 2008
Stats

Today I really harvested the full effect of our inclusion of Aspect Orientation, by using the Policy Injection block of Enterprise Library.

And I must say; I am in love! I hereby solemnly declare that I never will use any other way to implement non-functional requirements. As long as I have a say in the question.

Why - you ask? Because all other way is stupid! (I've picked up some Linus Torvalds style) Don't code - configure!

Here is the example that really convinced me; With a quite simple (very simple if you use the configuration tool for Enterprise Library) configuration block I got the results from all the methods in a certain interface (system values from database) to be cached.

Do you hear me? NO CODE did that! And it's so beautiful that my eyes are filled with tears.

Here is my configuration:

<!-- Caching policy for IDaVardeForrad REQUIRED! -->
      <add name="CachingPolicy">
        <matchingRules>
          <add type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.TypeMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Type Matching Rule">
            <matches>
              <add match="IdaVardeForrad" ignoreCase="false" />
            </matches>
          </add>
        </matchingRules>
        <handlers>
          <add expirationTime="00:01:00" order="0" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.CachingCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Caching Handler" />
        </handlers>
      </add>



Published by Marcus Hammarberg on Last updated