OONumerics User : |
From: Siddhartha Singh (singh_siddhu_at_[hidden])
Date: 2007-09-21 08:38:26
Hi Georg,
To me this seems difficult to implement as you don't want inheritance based approach and compile time binding. At the same time you want good OO design.
I may be wrong but in your case just design your class as good OO and use casting to have run-time binding yet no - virtual function call ( actually dynamic cast require vtable access ).
Because you will be using the same object's function. OR may be you can have mapping of objects in a map based on some key and then have if-else logic to get proper object and call the function of that object.
Do let me know if you get another good approach.
Cheers,
Siddhartha
----- Original Message ----
From: Georg Holzmann <grh_at_[hidden]>
To: oon-list_at_[hidden]
Sent: Friday, 21 September, 2007 2:56:36 PM
Subject: [oon-list] strategy design pattern without virtual functions ?
Hallo!
I have the following problem: In my class (= an algorithm) I have data
and some algorithms and it should be possible to exchange the algorithms
- perfect would be at runtime.
So usually one would maybe use the strategy design pattern for such a
problem.
However, I want to avoid virtual functions (performace critical methods)
and so it is unfortunately not possible with strategy (?) - yes, one can
implement strategy with early binding (with mixins or e.g. the Curiously
Recurring Template Pattern), but I want late binding if possible ...
Has anyone an idea which other approach I could try ?
I also thought about function pointers (or FastDelegates as e.g.
described here: http://www.codeproject.com/cpp/FastDelegate.asp), but
then its not such a nice OO design ...
Thanks for any hint,
LG
Georg
_______________________________________________
oon-list mailing list
oon-list_at_[hidden]
http://www.oonumerics.org/mailman/listinfo.cgi/oon-list
Why delete messages? Unlimited storage is just a click away. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html