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<IFlow>
to represent my schedule.
What do you think of this design, should I rather use three vectors vector<FeeFlow>
, vector<FloatingFlow>
and vector<FixedFlow>
to avoid the dynamic casts ?