By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,584 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,584 IT Pros & Developers. It's quick & easy.

A question about the Template Method design pattern

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I´m sorry for the previous message where my name appears obviously wrong.
Now it is corrected.

"Microsoft" <jm*******@gtfadrell.com> escribió en el mensaje
news:uz*************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #2

P: n/a
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)
Nov 15 '05 #3

P: n/a
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

"Juan M. Cervera" <jm*******@gtfadrell.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
I´m sorry for the previous message where my name appears obviously wrong.
Now it is corrected.

"Microsoft" <jm*******@gtfadrell.com> escribió en el mensaje
news:uz*************@tk2msftngp13.phx.gbl...
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


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.