-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implement op_once for form builder #105
base: master
Are you sure you want to change the base?
Conversation
This is breaking because `FormBuilder` is now an enum of two typestate variants.
Codecov Report
@@ Coverage Diff @@
## master #105 +/- ##
==========================================
- Coverage 96.95% 96.77% -0.19%
==========================================
Files 11 11
Lines 12670 12884 +214
==========================================
+ Hits 12284 12468 +184
- Misses 386 416 +30
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I changed it to use 3 states:
Potentially we could do away the outer FromBuilder and have a from() that collapses ANY/MANY to NONE once we save it back in the ThingBuilder. |
I looked at your changes, and after thinking a bit I still have the impression that it is more convoluted that it should be. This corresponds to your implementation: flowchart LR
thing((Thing)) -->|form| any[CAN_ADD_ANY_OPS]
any[CAN_ADD_ANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|op_once| none[CAN_ADD_NO_OPS]
many[CAN_ADD_MANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|from| Unlocked[FormBuilder::Unlocked]
many[CAN_ADD_MANY_OPS] -->|from| Unlocked[FormBuilder::Unlocked]
none[CAN_ADD_NO_OPS] -->|from| Locked[FormBuilder::Locked]
Unlocked[FormBuilder::Unlocked] --> Form
Locked[FormBuilder::Locked] --> Form
The only practical difference between this implementation and the previous one is that you cannot call
Given that this approach is just to fix some compile-time constraints elsewhere and that these constraints can be easily broken just deserializing a JSON representation (because you are not enforcing anything at runtime), I still think that this approach is more complex than it should be. |
As you may see in flowchart LR
thing((Thing)) -->|form| start[CAN_HREF]
start[CAN_HREF] -->|href| any[CAN_ADD_ANY_OPS]
any[CAN_ADD_ANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|op_once| none[CAN_ADD_NO_OPS]
many[CAN_ADD_MANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|from| final[FINAL]
many[CAN_ADD_MANY_OPS] -->|from| final[FINAL]
none[CAN_ADD_NO_OPS] -->|from| final[FINAL]
For the wot-serve use-case I might even consider adding a CAN_ADD_ONCE state that let you call |
Sorry, but I still don't get it. In your branch the only constraint you are creating is that the returned form does not have any operation set. This could be just implemented without |
Indeed we can potentially not have an flowchart LR
thing((Thing)) -->|form| start[CAN_HREF]
start[CAN_HREF] -->|href| any[CAN_ADD_ANY_OPS]
any[CAN_ADD_ANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|from| once[CAN_ADD_ONE_OPS]
once[CAN_ADD_ONE_OPS] -->|op| final[CAN_ADD_NO_OPS]
many[CAN_ADD_MANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|from| final[CAN_ADD_NO_OPS]
many[CAN_ADD_MANY_OPS] -->|from| final[CAN_ADD_NO_OPS]
once[CAN_ADD_ONE_OPS] -->|from| final[CAN_ADD_NO_OPS]
And have |
....which, again, brings to the fact that your last state is just the final |
Using more than a boolean let us avoid the FormBuilderInner, I started poking at it for that reason and then I realized it can be leverage to express more while I tried to use it in wot-serve. With the last commit I can correctly restrict |
Sorry, I unable to follow you anymore. From your previous message and the relative flowchart it was pretty clear it was possible to remove one state, you just added one instead. Feel free to go along with the idea you have in mind, it is pretty difficult to me at this point to write an implementation that makes sense in your head but not in mine. |
Here what I meant. I managed to reduce the states compared to the diagram above, I'm afraid we cannot collapse everything further in a single binary state, but we do not have flowchart LR
thing((Thing)) -->|form| start[CAN_ADD_ANY_OPS+NO_HREF]
start[CAN_ADD_ANY_OPS+NO_HREF] -->|href| any[CAN_ADD_ANY_OPS]
any[CAN_ADD_ANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|from| once[CAN_ADD_ONE_OPS]
once[CAN_ADD_ONE_OPS] -->|op| final[CAN_ADD_NO_OPS]
many[CAN_ADD_MANY_OPS] -->|op| many[CAN_ADD_MANY_OPS]
any[CAN_ADD_ANY_OPS] -->|from| final[CAN_ADD_NO_OPS]
many[CAN_ADD_MANY_OPS] -->|from| final[CAN_ADD_NO_OPS]
once[CAN_ADD_ONE_OPS] -->|from| final[CAN_ADD_NO_OPS]
(message delayed by a series of meeting) |
We ended up adding the constraints directly in wot-serve. In WoT 2.0 we might have either this constraint applied or not necessary anymore depending on what we'll have specified for the relationship between |
@lu-zero let me know if you'd rather tweak the struct names, i.e. a better one for
FormBuilderInner
.