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

Move parent attribute from SurveyElement to relevant subclasses #751

Open
lindsay-stevens opened this issue Jan 28, 2025 · 0 comments
Open
Labels

Comments

@lindsay-stevens
Copy link
Contributor

As noted here, not all SurveyElement subclasses will have a meaningful or useful parent assigned. This attribute should be moved to the subclasses where a parent is relevant, so that it is clear which objects should have this property. This should also reduce memory usage by removing an unnecessary attribute descriptor from every choice item (Option).

Consideration needs to be given to methods that reference the parent attribute i.e. the logic within these methods, and sensible location for them - such as helper functions or a mixin class. For example in SurveyElement, ._link_children(), .iter_ancestors(), .to_json_dict(), etc.

From a quick look it seems like the following use parent:

  • EntityDeclaration: child of GroupedSection(name="meta")
  • ExternalInstance: child of Survey
  • GroupedSection: child of Survey / GroupedSection / RepeatingSection
  • Question: child of Survey / GroupedSection / RepeatingSection
  • RepeatingSection: child of Survey / GroupedSection / RepeatingSection
  • Tag: child of OsmUploadQuestion

The following do not:

  • Section: not instantiated directly. Survey is a subclass so parent can't be here.
  • Survey: this is the top-most object
  • Option: these belong to an Itemset but are not nestable like Question / GroupedSection / RepeatingSection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant