Hello Luigi,
You wrote: I'm kind of puzzled
by this create() without arguments. Is this meant to
EuropeanOption
option = MyEuropeanOptionCalculator::create();
while in the second case the use would be: EuropeanOptionCalculator
calculator = MyEuropeanOptionCalculator::create();
In the first
case, setting up the factory would require the same parameters
EuropeanOption
option = myGlobalOptionMap["optionCode"];
Instead, if it
is a calculator that you want to create, it could be provided.
Sure, I agree. It is better to have an abstract factory as an external service. The intention with my idea is to encapsulate the parameters in the factory object, but as you argue below, this idea doesn't fit very well into this context. When you mention storing options in a map, makes me think of the Prototype pattern (Gamma et. al.). The idea is that the "instances" could serve as "classes" in run-time. So if I have two instances created from the EuropeanOption class, possessing different values, and both are stored in the map under different names. I could get a copy of either of them by doing:
EuropeanOption option = myGlobalPrototypeMap["name1"].clone();
Yes, it does now. Holidays
must have obfuscated my brain somehow :)
class OptionEngine
{
class EuropeanEngine
{
so that the engine
can already read the parameters and write the results
The template
class you propose, instead, is a useful device for making
class EuropeanEngine
: public xxEngine<EuropeanParameters,EuropeanResults> {
I'm pretty much in favor of adding this to the library. OK! Yes, I am also in
favor of adding some base templatized base classes
You wrote:
Well, I got some comments here though. "Templatize" sounds OK for me, but I honestly don't know if it is a correct word or not? The downcasting you suggest is perfectly OK for me, but I would like a wrapper around the parameters & results objects. This reminds me of the "Extension Interface" pattern and one well known implementation of it, Microsoft COM & ATL. Downcasting to a specific class, is like retrieving an interface. In COM, there is an interface called IUnknown (which is the most "known" interface of them all...). Every COM object must implement it. There are three methods: Release(), AddRef() and QueryInterface(). The first two provides life-time management. The last one is the most interesting in this context. It permits you to retrieve a pointer to any interface the object supports. "IID_IDispatch" is just a scalar ID. Such as:
IDispatch* pDisp;
I think it separates what you want to expose and not expose (i.e. facade/interface and pure implementation better). Life-time support wouldn't hurt either, sharing instances will be easier. A standard correspondance to an "IUnknown" implementation could be stored in the library. We have some further issues we would like to discuss with you: 1) In quantlib, there is a distinct separate class "Currency", which doesn't seem to be related with "Instruments"? In our view "Currency" IS-AN instrument! In our trading system, an order transaction always involve two instruments, the stock you want to buy/sell and the currency instrument you want to sell/buy in exchange. So trade a stock for money is equivalent to trade a stock for another stock. We think this way of thinking simplifies our code and is good design! Is there any reason why Currency cannot be an Instrument? What do you think? 2) We have a distributed environment, where the underlying middleware is TAO. TAO is a CORBA implementation. So current "Subject/Observer" implementation in quantlib's Instrument isn't much use to us, unless we are able to make it distributed. OK, maybe it is sufficient that we override the methods of the Quantlib::Patterns::Observable class. So for example, registerObserver(Observer*) would register the Observer instance in a CORBA event channel. The Observer instance must then be a CORBA object. Making our instrument both a "CORBA object" and an "Observer" can be solved with multiple inheritance, though. Our Observable instance must, in effect, be a CORBA event channel in this case. I would like a templatized Observer, where the template parameter would define the Strategy? Like:
template<STRATEGY>
So those who want another
way of distribution would benefit from a more decoupled way of
Bye,
|
Free forum by Nabble | Edit this page |