Skip to content
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

Refactor VariableSpec and StateItemSpec #2980

Open
tclune opened this issue Aug 21, 2024 · 3 comments
Open

Refactor VariableSpec and StateItemSpec #2980

tclune opened this issue Aug 21, 2024 · 3 comments
Assignees
Labels
📈 MAPL3 MAPL 3 Related

Comments

@tclune
Copy link
Collaborator

tclune commented Aug 21, 2024

For indirect reasons, it would now be preferable if subclasses of StateItemSpec have trivial constructors with an initialize() method doing more of the heavy lifting.

This could be done in two ways: (Consider FieldSpec is the poster child for StateItemSpec subclasses)

  1. field_spec = FieldSpec() ... call field_spec%initialize(variable_spec, _RC)
  2. field_spec = FieldSpec(variable_spec) ... call field_spec(_RC)

Originally I was thinking (1), but (2) has several advantages. In particular, it means that VariableSpec does not appear in the interfaces of StateItemSpec, and this may allow make_ItemSpec() to continue to live right where it is and require less total refactoring.

For now the call to initialize() can remain inside of make_ItemSpec(). Moving that to a new home is something I can do when I'm ready to exercise this functionality.

I will need this soon, so please be honest about level of effort you can apply.

@tclune tclune added the 📈 MAPL3 MAPL 3 Related label Aug 21, 2024
@darianboggs
Copy link
Contributor

There may be a dependency chain:

  1. mapl3g_VariableSpec depends on mapl3g_StateItemSpec and mapl3g_FieldSpec which in turn depends on mapl3g_StateIemSpec, currently.
  2. We want VariableSpec to pass itself into FieldSpec in the constructor called from make_itemSpec
  3. Therefore, the constructor for FieldSpec needs a VariableSpec argument.
  4. So, mapl3g_FieldSpec needs to depend on mapl3g_VariableSpec.

Is that correct? I can work around it, but I want to confirm:

  1. We don't want mapl3g_StateItemSpec to depend on mapl3g_VariableSpec.
  2. We want to defer initialization of FieldSpec objects after they are constructed.

@darianboggs
Copy link
Contributor

I think this:

  1. field_spec = FieldSpec(variable_spec) ... call field_spec(_RC)

should be this:

field_spec = FieldSpec(variable_spec) ... call field_spec%initialize(_RC)

@tclune
Copy link
Collaborator Author

tclune commented Aug 22, 2024

I think this:

  1. field_spec = FieldSpec(variable_spec) ... call field_spec(_RC)

should be this:

field_spec = FieldSpec(variable_spec) ... call field_spec%initialize(_RC)

Yes. Sorry.

tclune added a commit that referenced this issue Aug 25, 2024
tclune added a commit that referenced this issue Aug 26, 2024
…_state_item_spec

Feature/wdboggs/#2980 refactor state item spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 MAPL3 MAPL 3 Related
Projects
None yet
Development

No branches or pull requests

2 participants