Inheritance vs specific types in Financial Modelling for cashflows
Posted
by BlueTrin
on Stack Overflow
See other posts from Stack Overflow
or by BlueTrin
Published on 2010-06-07T10:18:33Z
Indexed on
2010/06/07
10:22 UTC
Read the original article
Hit count: 227
Hello, I have to program some financial applications where I have to represent a schedule of flows. The flows can be of 3 types: - fee flow (just a lump payment at some date) - floating rate flow (the flow is dependant of an interest rate to be determined at a later date) - fixed rate flow (the flow is dependant of an interest rate determined when the deal is done)
I need to keep the whole information and I need to represent a schedule of these flows. Originally I wanted to use inheritance and create three classes FeeFlow, FloatingFlow, FixedFlow all inheriting from ICashFlow and implement some method GetFlowType() returning an enum then I could dynamic_cast the object to the correct type.
That would allow me to have only one vector to represent my schedule.
What do you think of this design, should I rather use three vectors vector, vector and vector to avoid the dynamic casts ?
© Stack Overflow or respective owner