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

Rename fields in State to be more descriptive and add more detailed docs. #41

Merged
merged 8 commits into from
Jan 13, 2025

Conversation

andriyDev
Copy link
Collaborator

It can be difficult to understand the difference between the various Box<Behavior<A>> fields in State. I've renamed them to be more descriptive by switching most (but not all) from tuple structs to named structs.

Copy link
Owner

@Sollimann Sollimann left a comment

Choose a reason for hiding this comment

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

Great initiative! Looks good to me when scanning through the code. Can I get a second pair of eyes form you @kaphula before approving to make sure I didn't miss anything?

@andriyDev andriyDev mentioned this pull request Jan 12, 2025
@kaphula
Copy link
Collaborator

kaphula commented Jan 13, 2025

I think it looks good. No harm from more descriptive names and documentation. Thanks!

I had intentions to do the most simple use case for each behavior on their documentation entries with doc tests at some point, but only ever finished the WhileAll. I think having similar tests for other behaviors would be nice so you could instantly get a quick idea how a behavior can be used in practice without the need of studying the examples if possible. If you want to work on these as well, I'd be glad to have them, if that is ok with @Sollimann.

Copy link
Owner

@Sollimann Sollimann left a comment

Choose a reason for hiding this comment

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

@kaphula yes, I am happy with that as well. I think that could be a separate PR. Approving this one.

Feel free to squash and commit the changes @andriyDev , let me know if you don't have permission

@andriyDev andriyDev merged commit bbedfd9 into Sollimann:main Jan 13, 2025
2 checks passed
@andriyDev andriyDev deleted the rename branch January 13, 2025 15:39
Copy link
Owner

@Sollimann Sollimann left a comment

Choose a reason for hiding this comment

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

Approved!

TL;DR
I understand where you're coming from, and I appreciate the effort. Returning an Option feels like the most appropriate and lightweight solution for now. It avoids overcomplicating the api and keeps the door open for refactoring later if the need arises.

To your points:

1.) I think we disagree on the semantics here, which is fine. From my point of view ticking a finished tree is not inherently erroneous — it's an unsupported action, but not a failure of execution or logic. The only two possible states here are "tree produces a status" (some value) or "tree is finished" (none). If we ever encounter additional cases where we need more meaningful differentiation down the line, we can always refactor to introduce a more expressive type at that point. However, at the moment, Option is the simplest and most idiomatic fit for the problem we're solving (from my pov).

2.) I agree with this

3.) I also agree that thiserror are one of the more common and stable libs. I want to avoid dependency bloat which is common for so many libs out there. As the code evolves, if we encounter scenarios that truly require advanced error handling, we can reevaluate and introduce a proper error-handling strategy (including dependencies) then

@andriyDev
Copy link
Collaborator Author

@Sollimann I think you may have approved/replied to the wrong PR haha

@Sollimann
Copy link
Owner

Ups, don't know how I managed to do that haha @andriyDev

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.

3 participants