-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModelParameters
needs proper encapsulation.
#84
Comments
I am excited to see that happening!! |
Well, I was actually planning on maybe asking whether you would be happy to be assigned to this issue, after we're done with #87? :) |
Or I can have a shot at it.. because it may be not as trivial as it sounds? I'm concerned whether we should wait on #113 to happen first, so as to not trigger to much churn for you @evadelmas? |
Alé, #113 is moving closer to the finish line. I'll start the work on this :) |
Featured by #131. |
I somewhat worry that:
ModelParameters
struct.... will eventually trigger a lot of churn because, as of today, all user code relies on explicit, direct accesses to
ModelParameters
fields. For parameterx
for instance, access is eitherparms.x
orparms.biorates.x
orparms.environment.x
orparms.functional_response.x
orparms.producer_competition.x
etc. The first downside of this is that it's not always easy to understand where to findx
. The second downside is a bigger problem, because every future change toModelParameters
is potentially breaking.Starting now, I suggest that we stop exposing
ModelParameters
fields to user and offer instead a whole bunch of abstract, controlled accesses like:x = get_x(parms)
for read-only accesses. The resultingx
is a copy of internal parameters and can be modified by the user without altering the state ofparms
.set_x!(parms, value)
for write-only accesses. The value ofparms
is modified accordingly and all internal checks can be run.x = ref_x!(parms)
for aliasing accesses (read/write). The resultingx
is a direct reference to internal parameters and can be modified to alter the state ofparms
. Use with caution.This essentially boils down to adding a large list of such methods somewhere in the package sources. To ease the transition, all package code with direct
parms.x
accesses can remain as-is in a first time. But all tests/docs/doctests need to be rewritten to useget_x(parms)
etc. instead, so the user won't rely onparms.x
.With this out of the way, future evolutions of
ModelParameters
should not become an endless source of dread, fear and nightmares ;) Also, it would nicely leverage with #73.The text was updated successfully, but these errors were encountered: