473,791 Members | 3,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A question about the Template Method design pattern

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 doesnt work.
I would appreciate your help ver much.
Thank you

Juan M. Cervera
Nov 15 '05 #1
3 2948
Im sorry for the previous message where my name appears obviously wrong.
Now it is corrected.

"Microsoft" <jm*******@gtfa drell.com> escribi en el mensaje
news:uz******** *****@tk2msftng p13.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 doesnt work.
I would appreciate your help ver much.
Thank you

Juan M. Cervera

Nov 15 '05 #2
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
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*******@gtfa drell.com> wrote in message
news:uk******** ******@TK2MSFTN GP11.phx.gbl...
Im sorry for the previous message where my name appears obviously wrong.
Now it is corrected.

"Microsoft" <jm*******@gtfa drell.com> escribi en el mensaje
news:uz******** *****@tk2msftng p13.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 doesnt work.
I would appreciate your help ver much.
Thank you

Juan M. Cervera


Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3627
by: Dave Rahardja | last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at work. He is a proponent of the Template Method pattern, i.e.: class foo { public: void bar() { do_bar(); } protected: virtual void do_bar() {} };
7
12480
by: Tim Clacy | last post by:
Is there such a thing as a Singleton template that actually saves programming effort? Is it possible to actually use a template to make an arbitrary class a singleton without having to: a) explicitly make the arbitrary class's constructor and destructor private b) declare the Singleton a friend of the arbitrary class
8
3154
by: Tony Johansson | last post by:
Hello Experts! What does this mean actually. If you have a template with a type and non-type template argument, say, like this template<typename T, int a> class Array {. . .}; then A<int, 1> and A<int, 2> are different types. Now, if the A template
6
4009
by: RainBow | last post by:
Greetings!! I introduced the so-called "thin-template" pattern for controlling the code bloat caused due to template usage. However, one of the functions in the template happens to be virtual as well. To support thin-template, I need to make virtual function as inline. Now, I know that compiler would generate an out-of-line copy when it
3
1788
by: cmay | last post by:
In reading some documents from the Patterns and Practices group, I had a question about the example given for the Page Controller pattern. (I have posted the code for the BasePage below) In short, their example shows a "BasePage " class for other pages to inherit from. The subclasses are supposed to implement the PageLoadEvent method (which I guess should really be abstract, but can't because asp.net
12
2753
by: yuyazhang | last post by:
Hi , I am a graduate , I have had some basic knowlege about C++ ! but I find that I can't master it , I am disappoint for that . who give me some advice about ways which master it and some good books 。I will be pleasure. Thank you in advance!
0
1266
by: ltruett | last post by:
....and I've finally completed my series of GOF design patterns using PHP 5 with the Template Pattern. http://www.fluffycat.com/PHP-Design-Patterns/Template/ This is a pretty useful pattern, and one that you could easily use without even realizing it is a pattern. Essentially you have an abstract template class that defines a non-abstract method with an algorithm. Also in the abstract template
11
2175
by: rogo | last post by:
Ok, when I began to implement it, I thought it should be straightforward and easy. I'm not sure whats wrong with the following code: class A { public: A() {} int get() {
2
2567
by: Duy Lam | last post by:
Hi everyone, Sorry, I don't know what group to post this problem, I think may be this group is suitable. I'm styduing DAO (Data Access Object) pattern in this link http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html. While I've read about implementing Data Access Objects by Factory Method Pattern (http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_07.gif) and Abstract Factory Pattern...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.