Posted by
Luigi Ballabio-2 on
Oct 27, 2002; 5:01am
URL: http://quantlib.414.s1.nabble.com/call-for-void-constructors-tp10165p10168.html
At 1:58 PM -0500 10/26/02, Vadim Ogranovich wrote:
> [Vadim] Well, this will work, but it's a HACK and ,worse, it
>breaks "encapsulation" of FdDividendAmericanOption since now I need to know
>that its constructor doesn't perform any calculation, and those people who
>modify FdDividendAmericanOption class need to know that too, otherwise they
>will break my new class.
Hmm. Yes, you're mostly right and I was mostly wrong, so I won't go
and start dotting i's and j's. init() might just be the least of
evils.
> To make this discussion a little bit more concrete (but not
>too much :-)) consider writing a function which given option characteristics
>returns the most efficient pricer for that option, e.g.
>
> SingleAssetOption * getMostEfficientPricer(...).
>
> Without default constructors the argument list of the
>function must include all parameters possibly needed by actual constructors
>(fat parameter list). This is certainly not good as this list is likely to
>change when you add new pricers or add parameters to the old constructors.
I'm not entirely following you here. Won't you have the same problem
with init(), i.e., won't init() suffer from the same
fat-parameter-list problem? And if not, how will you know which kind
of pricer was returned so that you can pass the right parameter list
to init()? All you will get is a pointer to the base class...
Later,
Luigi