Tuesday, April 29, 2008

Design Patterns – Template method

The idea is to design a method in a superclass that defines the skeleton of an algorithm. Implementation of varying steps in the algorithm is deferred to a subclass. The superclass can implement a default.

An example would be to create a mechanism for caching objects. The logic for how to cache objects remains the same so we create a template method for it. However, the means for how to get the object from storage differs so it is left to the subclass to implement. The logic is something like:

if (IsObjectInCache(anObjectKey))
{
return GetObjectFromCache(anObjectKey);
}
else
{
Object anObject = GetObjectFromStorage(anObjectKey);
SaveObjectInCache(anObjectKey, anObject);
}


The SaveObjectInCache is then overridden in the subclass.

However, for this example this pattern might not be ideal for this situation. Since caching is normally an application wide concern it might be better solved using an AOP technique or somehow implementing it more loosely using in combination with the Decorator pattern.

Another possible approach would be this: Have all business entities implement a single interface that takes their key (in form a Dictionary object created automatically by using reflection) and loads the object representation. Then have a CacheManager implementing the method skeleton.

So remember that the drivers behind this pattern can be created using some other technique than subclassing.

Monday, April 21, 2008

BízTalk ESB and other fun stuff

I am planning to play around some with the following technologies:

Enterprise library Policy Injection Block. I'll check this one out to see if it in conjunction with the other blocks can solve some of the mundane plumbing I regularly perform. Example of things I would like to have declarative / configuration support for is:

1. Validate parameters.
2. Log parameter values in cause of exception in methods.
3 Log execution time in methods.

I need to check what kind of constraints this puts on my classes. Ideally it should work with PONOs and static methods and be as transparent as possible. I am not convinced that this is the case from what I have read but I just implemented an automatic logging of parameter calls including parameter values and it was pretty cool.

ASP.NET MVC. I need to pick up this one really bad. It is a real pain to implement complex flows in e-commerce apps for instance using regular ASP.NET controls if you just code . This is because of the Post Back model I think.

Micosoft ESB. Using this one in a project and I am in need to adapt some of the code to support the setting of an itinerary programmatically from the BRE for instance inside an orchestration. The problem is that we cannot / do not want to set the itinerary information in the SOAP / WCF header since the message is coming in as file to be picked up by the FILE Adapter. Instead we’ll create an orchestration that subscribes to the message once it is in the message box and sets the itinerary programmatically.

There is lots of cool stuff in this package although you find many of the possibilities it opens up and where to apply them quite confusing. I mean, BTS offered a few options in different areas already before this one. For instance should I use a custom orchestration or itineraries if am doing basic processing? If I am using itineraries in combination with receiving messages from an external system how should the itinerary header be set? If it could be set by an ESB Resolver in the pipeline that would be great I think.

It is really cool that the Patterns & Practices distributes the source for the ESB. I like where Microsoft is going with .NET and I don’t think about switching focus to Java anytime soon although I would love to play with stuff like the upcoming EJB (finally starting to deliver huh?) or ServiceMix.

On another note I need to structure my .NET resources and find more community sites that I feel as passionate for as for the outstanding Java site theserverside.com. Currently I usually check out the following:

theserverside.net
codeplex.
BizTalk blogs from Loesgen and others every now and then. I really like the vivid BizTalk community.
NET Rocks podcasts. I usually listen to this stuff when my eyes are tired from coding but my brain still has some to give J
The Architecture Journal.
BizTalk HotRod.
Microsoft Pattern & Practises.

I would also like to check out the new Microsoft stuff around ORM but it can wait some I guess since I am really happy using NetTiers at the moment. Too little time, too much fun J

Thursday, April 17, 2008

Kortspec

Köpte KappAhl för några dagar sedan på 50.25 och sålde av på 51.5. Skulle behållt längre, men aktien var kanske inte så stark som jag förväntade mig. Gjorde dock liten vinst på 550 SEK före skatt.

Sunday, April 13, 2008

Uppdatering

Eniro visar hyfsad styrka trots relativt svag börs vilket bådar gott för framtiden. Håller annars ett öga på Ericsson ned mot 11 kronor. Andra kandidater är KappAhl, PA Resources och RnB.

Wednesday, April 02, 2008

Uppdatering på aktiefronten

Sålde av 4000 Ericsson med liten vinst i förhoppning om att köpa tillbaka billigare senare. Hade snitt på 12.01 och fick 12.22.

Ligger nu med 1000 ENIRO som borde kunna utvecklas fint inför utdelningen förutsatt att börsen int är allt för skakig.