MRC-CSO-SPHSU / LoneParentsModel.jl

An initial implementation of an ABM for social and child care
0 stars 5 forks source link

how to keep cross-cutting but optional model parts separate (e.g. social class)? #52

Open mhinsch opened 2 years ago

mhinsch commented 2 years ago

I would rather not have if pars.useClass peppered throughout the code...

AtiyahElsheikh commented 2 years ago

Example please for an alternative?

mhinsch commented 2 years ago

It's a genuine question, i.e. I don't have a perfect solution either. For social class what I did was to factor out the code that used social class into separate functions which can then be swapped out (relatively) easily if necessary.

AtiyahElsheikh commented 2 years ago

I am thinking if we delegate each parameter as a a function argument, there could be cases with functions requiring so many arguments. On the other hand, having parsas an argument is a way to unify (as much as possible) how low-level translated unit functions .. doX(people,pars,data,etc.)

AtiyahElsheikh commented 2 years ago

Not also ignoring potential code extendability / modifiability, we rather extends the fields of pars rather than function prototype.

AtiyahElsheikh commented 2 years ago

Just though about naive solution this morning, if I understood correctly struct fields to be converted into named tuples and making use of the operator...