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

Add base methods for Schemas and Nodes to handle children with pathli… #523

Merged
merged 11 commits into from Mar 23, 2020

Conversation

HaluskaR
Copy link
Contributor

…ke names

This is to open discussion on naming, further tests, gotchas, etc. Still need to add remove methods and other niceties.

@coveralls
Copy link

coveralls commented Mar 13, 2020

Coverage Status

Coverage increased (+0.05%) to 85.599% when pulling 82cd155 on haluska2/initial_support_for_paths_as_names into ccf13ca on master.

@HaluskaR
Copy link
Contributor Author

Naming-wise, get_child vs. fetch_child is a bit confusing, since there's not a concrete difference between "get" and "fetch". Schema has both a shallow and deep check ("has_child" vs "has_path"), which I think works really well. child vs. descendant might also make sense, though in this case, the child is what the newer method is getting, and "descendant" is a bit cumbersome

@HaluskaR
Copy link
Contributor Author

HaluskaR commented Mar 13, 2020

I was wondering about the coveralls coverage...turns out I only committed the src/libs, not the tests. d'oh! One sec.

@cyrush
Copy link
Member

cyrush commented Mar 13, 2020

so far this is looking good!

I am open to making an API breaking change here to get to a better set of names.
I agree has_child vs has_path is good, maybe we move to change node::fetch_child.

Let me mull it a bit more.

One way to test this would be to make the change and see if any of the unit tests make assumptions.

}
size_t idx = (size_t)m_schema->child_index(name);
return *m_children[idx];
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will also need a non-const implementation, I think thats issue the CI is pointing out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do! I expect logic to be identical between the two since it's only a getter. Given that, do you have preference for the implementation? I know the brief way is to have the non-const implementation temporarily const-cast then call the const function, Effective C++ style, but other projects prefer having the two full methods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with two methods, since they are pretty short. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@cyrush
Copy link
Member

cyrush commented Mar 18, 2020

Looks good! I am going to add some unit tests to look at json + yaml, roundtrip.

@cyrush
Copy link
Member

cyrush commented Mar 18, 2020

Update on my thoughts on naming:
I think we can change get_child to just child, node already has Node::child(index_t index) that provides similar semantics to what we want for get_child, seems much cleaner. What do you think?

Pushing a bit further with testing, it seems we will have to re-plum some operations, like generic sets of nodes, diffs, etc. B/c they are using generic fetches.

I'll try to get a unit test that covers most these cases and then we can attack.

@cyrush
Copy link
Member

cyrush commented Mar 18, 2020

@HaluskaR fixing some of the internals will be on my plate -- I am digging in on that, and I'll work on this branch.

@cyrush
Copy link
Member

cyrush commented Mar 19, 2020

@HaluskaR I think I am converging on child as the new method names.

I started to fix some of the tricker internal changes and a small bug with add_child.
I still need to fix the generator code (which handles JSON and YAML parsing)

@cyrush
Copy link
Member

cyrush commented Mar 20, 2020

@HaluskaR I think this might be ready to merge, I updated the change log and added you to the contributors. Do you want to put it through any more of your own testing?

@HaluskaR
Copy link
Contributor Author

Thank you for adding the tests and all the internals! Looks like all the cases that spring to mind are covered--I'll check while I wait for the last CI to complete and then perform the merge.

@HaluskaR HaluskaR merged commit aa2de17 into master Mar 23, 2020
@cyrush cyrush deleted the haluska2/initial_support_for_paths_as_names branch July 20, 2021 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants