A question about the Template Method design pattern

  • Thread starter Thread starter Microsoft
  • Start date Start date
M

Microsoft

Is there a way of implementing something like the Template Method design
pattern, but only dealing with static methods ?
First, I realized that I can't have abstract static methods in the base
class to be implemented in the derived classes.
Second, I have tried to hide those methods of the base class, with the 'new'
modifier, bub it doesn´t work.
I would appreciate your help ver much.
Thank you

Juan M. Cervera
 
I´m sorry for the previous message where my name appears obviously wrong.
Now it is corrected.
 
while you can't use inheritance you can still use
containment: use events and let container do the work in
the event handling routine.

hth (luKa)
 
Juan,
In addition to the suggestion of using (static) Events.

You might be able to use a static Delegate variable, which is set to the
Template Method of the derived class.

I would consider creating an implementation class that has the overridable
template method in. Treat this implementation class as a singleton, where I
have a single instance of the 'derived' class in the base classes static
variable. Then my base's static method would call the method on this
implementation class...

I would consider making this implementation class nested with a visibility
of protected to the base class. The 'derived' class would have their own
derived implementation classes. The derived class would need to 'register'
their implementation with the base class, I think I would use a custom
setting in app.config to register this derived implementation class.

Hope this helps
Jay
 
Back
Top