Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Workflow] added a TransitionsCollectionBuilder so DefinitionBuilder doesn't need Transition objects#20498
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
xabbuh commentedNov 12, 2016
What about supporting both ways (we would still need to think about good method names). That would not force the user to deconstruct already existing By the way, you also need to update the constructor's docblock. |
HeahDude commentedNov 12, 2016
I'm not a fan of supporting both, but why not? I tend to prefer the BC break though, the commit has only three days and this is a lot nicer to me. I get used to not have any |
xabbuh commentedNov 12, 2016
I was more thinking about use cases where you are reusing parts on an existing workflow definition. |
HeahDude commentedNov 12, 2016
I understood#20451 was giving two possibilities. Either use one builder per definition, or keep using the same builder to add some transitions making the first a subset of the second. So I don't see the need to support what you're thinking about. |
xabbuh commentedNov 12, 2016
If the definition wasn't build through the builder there is nothing you could based the next definition on (except we made it possible to initialise the builder with an existing definition). |
HeahDude commentedNov 12, 2016
Ok got you, I'm going to fix this. Status: needs work. |
HeahDude commentedNov 12, 2016
Status: needs review |
17c4169 to99a8887Comparexabbuh commentedNov 12, 2016
Can you make fabbot happy too? :) |
| * @param string[] $places | ||
| * @param Transition[] $transitions | ||
| * @param string[]$places | ||
| * @param(Transition|array)[] $transitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think this deserves some explanation about how such an array must be composed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Shouldn't this simply be@param Transition[] $transitions?
| } | ||
| /** | ||
| * @param (Transition|array)[] $transitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
same here
| } | ||
| /** | ||
| * @param Transition $transition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
not needed
| /** | ||
| * @param Transition $transition | ||
| */ | ||
| publicfunctionaddTransition(Transition$transition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why does this method not support an array too?
| * @param string[]|string $froms | ||
| * @param string[]|string $tos | ||
| */ | ||
| publicfunctioncreateTransition($name,$froms,$tos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
not sure this method belongs to the builder to be honest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
the method name is misleading, because it does not only create the Transition (which would return it for usage) but instead it creates it internally and then adds it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok go for a polymorphaddTransition.
| * @param string[]|string $froms | ||
| * @param string[]|string $tos | ||
| */ | ||
| publicfunctioncreateTransition($name,$froms,$tos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
the method name is misleading, because it does not only create the Transition (which would return it for usage) but instead it creates it internally and then adds it
| array('t4','d','f'), | ||
| array('t5','e','g'), | ||
| array('t6','f','g'), | ||
| )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
why changing all these tests ? They are unrelated to your change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I originally removed the possibility to pass instances, and then I did not change back the tests because I found them much more readable like this, don't you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Na, I do not think it is more readable. Sorry =)
But it is a matter of taste.
58d4884 to3562fadCompareHeahDude commentedNov 12, 2016
Ok comments addressed here, thanks! |
3562fad toe70fdf3Comparee70fdf3 tof900e2bCompare
Nyholm left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Im not to sure this is needed. Is the argument only for convenience?
Anyhow, We need to validate the inputs properly so we do not cause any weird type errors.
| array('t4','d','f'), | ||
| array('t5','e','g'), | ||
| array('t6','f','g'), | ||
| )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Na, I do not think it is more readable. Sorry =)
But it is a matter of taste.
| if ($transitioninstanceof Transition) { | ||
| $this->transitions[] =$transition; | ||
| }else { | ||
| $this->transitions[] =newTransition($transition,$froms,$tos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We have to validate the input here. What if some does:
$builder->addTransition('foo','bar');
| if ($transitioninstanceof Transition) { | ||
| $this->addTransition($transition); | ||
| }else { | ||
| list($name,$froms,$tos) =$transition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We have to validate input. What if someone does:
$builder->addTransitions([['foo','bar']]);// Or$builder->addTransitions(['foo']);
ro0NL commentedNov 13, 2016
Cant we introduce a |
HeahDude commentedNov 13, 2016
And I think exactly the same as you ;)
|
Nyholm commentedNov 13, 2016
But isn't this overkill just to avoid writing |
ro0NL commentedNov 13, 2016
@HeahDude :)) but that affected direct user-land php configuration files, which made it considerable. And eventually the union type was avoided anyway (hence i think here it should also). In this case we could convert arrays to transition objects in the FrameworkExtension (using its own builder). |
ro0NL commentedNov 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Otherwise, maybe adding $builder->addTransition($builder->createTransition($array)); |
Nyholm commentedNov 13, 2016
Sorry but I fail to understand why... $builder->addTransition($builder->createTransition($array))// or$builder->addTransition($builder->createTransition('foo','bar','baz')) ... is better/simpler/more convenient than: $builder->addTransition(newTransition(foo','bar','baz')); |
ro0NL commentedNov 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It's not. But it could be useful to have it when transforming configs into objects. |
Nyholm commentedNov 13, 2016
You meanthis line in FrameworkExtension would be: $transitions[] =array($transitionName,$from,$to); Is that the only win for this PR? |
ro0NL commentedNov 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Agree. I was already looking at it... this isnt actually needed to improve that. So, we have a definition builder for user-land, what about a transition builder as well? $t = (newTransitionBuilder()) ->addTos($tos) ->addTo($to) ->build(); |
HeahDude commentedNov 13, 2016
I've taking your comments into account already and started to work on it, I'm pushing it soon. |
Nyholm commentedNov 13, 2016
Again, why is $t = (newTransitionBuilder()) ->addTos($tos) ->addTo($to) ->build(); better/simpler than just: $t =newTransition(foo','bar','baz'); |
ro0NL commentedNov 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Again.. it's not :) guess it's matter of preference? Imo. it would be just as useful for having the Maybe we should re-consider that one first 😕 Ie. if we default the initial place to first available place directly in the As it was already removed from the framework extension for the same reason; overkill. Basically saying; it'spractically not needed. |
fabpot commentedNov 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Reading the comments, I agree that we should keep things simple. I still don't understand which problems this PR is trying to solve... but I do understand it adds complexity to the code. 👎 |
HeahDude commentedNov 13, 2016
@Nyholm that's not what I've in mind, tests are failing, but I've pushed my concept. |
HeahDude commentedNov 13, 2016
@fabpot I've just totally refactored it, one file to hold a new responsibility and a few lines changed. |
cf0c1b5 to4814896Comparefabpot commentedNov 13, 2016
I still fail to understand the issue and why this is a better than what we have today. Can you explain? |
HeahDude commentedNov 13, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
When using a But by introducing this transitions collection factory some tests are now failing because we use some definitions with invalid transitions and this actually looks like an issue IMHO. |
fabpot commentedNov 13, 2016
So, you're saying that it' better to use an abstraction and hide the |
25f7813 toc8a5882Comparec8a5882 to1530498CompareHeahDude commentedNov 13, 2016
Ok then, closing here. Thanks everyone for the feedback. |
xabbuh commentedNov 13, 2016
I am still not completely against this change, but I would rather provide two different methods. One were you pass a |
lyrixx commentedNov 14, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The more I think to this PR and to the DefinitionBuilder, the more I think the DefinitionBuilder is not really needed. It does not really help to reduce the number of LOC. Example: $transitions = [newTransition('name','A','B'),newTransition('name2','B','C'),];$definition =newDefinition(['A','B','C'],$transitions);(newDefinitionBuilder()) ->addPlaces(['A','B','C']) ->addTransition(newTransition('name','A','B')) ->addTransition(newTransition('name2','B','C')); What do you think? Note: I'm agree with@fabpot about this PR and I'm also 👎 with its current state |
HeahDude commentedNov 14, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@lyrixx It's not about the LOC, it's about being able to add transitions without passing them to the constructor and keeping the |
Uh oh!
There was an error while loading.Please reload this page.
I suggest to not construct
Transitionobject repeatedly in user land code, ortherwise we can just create our ownDefinition, let's abstract it in the builder.ping@lyrixx@Nyholm