Monday, May 11, 2009

Geek Hero Comics

Geeky comics that covers developer-hacker-project manager relationships and tussles, Open Source software, anti-Microsoft culture, Linux, Git etc.


Comics are updated more than once, within a week. Some only discuss the recent trends or buzz in the software industry but on the whole there is an intriguing story line with adorable characters that keep you wanting for more.

I recommend you geeks to go through the whole comic strip and like me, wait for more.
Here you go:
http://www.geekherocomic.com/

Tuesday, May 5, 2009

TMA or simply Polymorphism?

Template Method Algorithm aka TMA (GoF) has been my all time favorite among Design Patterns. You can find a very good explanation of TMA in 'Head First Design Patterns' as it sheds light on some aspects even missing in GoF. Here are some slides on TMA that I made few years back:



Simply put, it streamlines the most trivial usage of polymorphism. This makes it a candid member of many compound patterns.

One pitfall that I have run into on quite a few occasions is when I try to make my base algorithm encapsulate lots of logic in order to maximize code reuse, pulling even minimally repeated piece of code from the concrete algorithms and placing it in the base algorithm. This all seems to be good and powerful until there come changes specific to the concrete algorithms forcing the common logic in the base algorithm to break.
Another trap of this trivial pattern is that it makes it easy to foresee inclusion of code in the base algorithm which lies outside of the algorithm's scope. Yet again, this is due to it's closeness with the polymorphic theme that the distinguishing line between 'simple polymorphism' and 'usage of polymorphism in TMA' starts to diminish.

Hence, following SRP (Single Responsibility Principle) is the key to writing a successful TMA and not transforming it into one of those god classes.