template-methods

Templated delegates

I have the following piece of code pattern: void M1(string s, string v) { try { // Do some work } catch(Exception ex) { // Encapsulate and rethrow exception } } The only difference is that the return type and the number and types of parameters to the methods can vary. I want to create a generic / templated method ...

Object's state in the Template method design pattern

Here is an implementation example of the algorigthm in the base absctract class from http://sourcemaking.com/design_patterns/template_method/php public final function showBookTitleInfo($book_in) { $title = $book_in->getTitle(); $author = $book_in->getAuthor(); $processedTitle = $this->processTitle($title); $processedAuth...

Is it a good practice to implement Template Method Patter via C# events?

I am now trying to understand some code and I have found a pattern, which seem a bit strange to me. There is a user's control class with 'EditorOpen' event. At first, I thought this name is incorrect, because it does not end with '-ing' or '-ed', as MSDN suggests. However, later I have found out, that this event does not INFORM about som...

Template method pattern

Can anyone let me know some example situations where Template Method - pattern should be used? Give me some real-world use from your own experience. (I have so far found it useful only for mapping data in the DA layer. Sorry!!!) ...

SRP applied to a workflow example: how to structure the classes in a sensible way

I have a problem with deciding about class responsibilities. I have 3 html-forms: For each form there is a html template containing some text and a marker for the form to be included Each form needs to be validated, if there is an error the template and the form from (1) needs to redisplayed, together with some error messages. Only som...

Make C++ call the right template method in an un-ugly way

I'm cooking up a vector library and have hit a snag. I want to allow recursive vectors (i.e. vec<H,vec<W,T> >) so I'd like my "min" and other functions to be recursive as well. Here's what I have: template<typename T> inline T min(const T& k1, const T& k2) { return k1 < k2 ? k1 : k2; } template<int N, typename T, typename VT1, typename...