I have been going back and forth between C# and Java for the last 8 years.
One thing that strikes me is that I have completely stopped using the "Template Method" design pattern in C#. Actually, in C# I Have come to think of this pattern as an anti-pattern.
http://en.wikipedia.org/wiki/Template_method_pattern
Coming back to Java, I find the pattern is alive and kicking. I still think it looks antique, but realise that there's no other way to do this in java. Java looks antique too ;)
Since this is going to come up anyway, Why is it an antipattern ?
So with closures/delegates/function pointers, you normally pass around some function instead of subclassing.
So back to the question:
If your language has closures/delegates/function, do you use the Template Method, and when?
When I used Java, yes. But for languages with "closures/delegates/function", Lua in my case, no I don't anymore, instead I've been leaning more and more towards decoration pattern for most of my needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With