Closed ChrisCScott closed 5 years ago
We're opting for stronger encapsulation. SubForecast instances do not have access to each others' state. They may communicate only by mutating available
, which is passed between them in the order defined by Forecast
.
A working implementation of Forecast
and SubForecast
based on this model is provided in the develop
branch via the above commit.
Each
SubForecast
object may need to obtain values calculated by otherSubForecast
objects. For example,IncomeForecast
may need to access thetotal_tax_withheld
andtotal_tax_owed
attributes ofTaxForecast
for the previous year.In general, each
SubForecast
may need to access a value (a) for the current year from anySubForecast
preceding it in the model or (b) for an earlier year from anySubForecast
. Earlier planning only accounted for (a) (see #40).We can simplify this considerably by simply passing each
SubForecast
a reference to either the parentForecast
or to all of its siblingSubForecast
objects. The former approach seems like the most straightforward, though it makes the encapsulation of eachSubForecast
somewhat less strict.