Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Ask Luigi

October 11th, 2007, 7:14 pm

Luigi and all,I have some questions on Templates vs OOP, in particular policy classes; 1. The template template parameter idea, is that a kind of Bridge?2. Template member function uses a parameter that is a kind of Strategy?So, as a Strategy is a lightweight Bridge, then TMP is a kind of localised TTP??? thx
Last edited by Cuchulainn on October 10th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Ask Luigi

November 15th, 2007, 7:24 pm

Quote1. The template template parameter idea, is that a kind of Bridge?yes, and much more robust than the GOF OO version.
Last edited by Cuchulainn on November 14th, 2007, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Ask Luigi

March 7th, 2009, 3:28 pm

I see that boost 1.38.0 has support for Flyweight. Could this pattern be used to solve the 'Singleton' problem?
Last edited by Cuchulainn on March 6th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
lballabio
Posts: 0
Joined: January 19th, 2004, 12:34 pm

Ask Luigi

March 9th, 2009, 7:35 am

It depends on your Singleton problem.
 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Ask Luigi

March 9th, 2009, 7:49 am

QuoteOriginally posted by: lballabioIt depends on your Singleton problem.The classic GOF solution.
 
User avatar
lballabio
Posts: 0
Joined: January 19th, 2004, 12:34 pm

Ask Luigi

March 9th, 2009, 8:42 am

If you're using Singleton to save memory or space or instantiation time, you should really use Flyweight.If you're using Singleton because there's a constraint in your domain (note: domain, not implementation) that there should be only one of it, use Singleton.Using one or the other should express intent.Luigi
 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Ask Luigi

March 9th, 2009, 8:59 am

Some random samplesSingletons are used inappropriately because people confuse having to make something single-instance with only *needing* (edt.) a single instance at the time - two very different things.The biggest problem is Maintainability; in the limit when the numbers of Singletons increases, the C++ morphs into Cobol data divisions.
Last edited by Cuchulainn on March 8th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Ask Luigi

October 26th, 2016, 6:16 pm

C++11 has std::type_traits. Dry stuff and a bit mind-numbing without some app examples.

I want to write a small app to show how and if they are useful .. for intermediate level.
Any examples in QuantLib, for example?

thanks/grazie!