[java] Actions javadoc: #perform vs #build #8412
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Slightly improving the documentation.
Pointing out that it’s #perform what the user needs to call at the end of the method chain to actually perform the actions.
Motivation and Context
It would be natural for one who is familiar with the Builder pattern, and it's the first time that he/she uses the Actions class (exploring the API with method completion), to come up with something like this:
And expect that it will work.
Then, when they run their test and find that something didn't work, it's not going to be easy to figure out what went wrong. More specifically, to trace it back to the call to
build()
.This PR is trying to solve that by adding a warning in the javadoc.
Although I would prefer the build() method to behave as perform() (and deprecate perform() afterwards).
This comes from a personal experience, where I tried to use the Actions class after some time (a few years) I hadn't used it and I forgot that you need to call perform() and not build().
Types of changes
Checklist