[Improvement][API] Simplify the Check of Result by introducing several new methods.#5666
[Improvement][API] Simplify the Check of Result by introducing several new methods.#5666CalvinKirs merged 11 commits intoapache:devfrom echohlne:refactor_Result
Conversation
check code style has some errors.
Codecov Report
@@ Coverage Diff @@
## dev #5666 +/- ##
============================================
+ Coverage 45.29% 45.34% +0.05%
- Complexity 3672 3681 +9
============================================
Files 607 607
Lines 24794 24797 +3
Branches 2803 2803
============================================
+ Hits 11230 11245 +15
+ Misses 12493 12479 -14
- Partials 1071 1073 +2
Continue to review full report at Codecov.
|
| return new Result<>(data); | ||
| } | ||
|
|
||
| public boolean isSuccess() { |
There was a problem hiding this comment.
Hi, to be honest, I don't recommend modifying this class, this may be related to programming habits :).
I think this class should be kept as simple as possible, he shouldn't care about the status judgements.
Another point is that if we add more status judgements in the future, we need to modify this class again.
For example, if we add a new status of result called unknown, then we need to modify this class and add a new method, am I right?
But you are right, right now there is a lot of duplicate code in many placements, once we need to change the rule of status judgement, we need to modify many placements. I may prefer to use a new class to take care of the status judgement, rather than modified the current class.
There was a problem hiding this comment.
Thanks@ruanwenjun I'll close this pr.
There was a problem hiding this comment.
@Kyoty This is my own opinion, you can open this pr and discuss with more people.
There was a problem hiding this comment.
@ruanwenjun thanks, what you said is very valuable, I will collect other's opinions to decide what to do next.
There was a problem hiding this comment.
In my opinion, this is a public method, and I think it can be done so.
There was a problem hiding this comment.
Thanks @CalvinKirs , do you think this pr makes sense? Or is there a better way to deal with it?
|
please resolve the conflicts file.thx |
|
@CalvinKirs solve it! |
|
Kudos, SonarCloud Quality Gate passed! |
Purpose of the pull request
Try to introduce several methods like below in
Result:The purpose of this is to reduce some tedious template code:
The
Brief change log
No new features, using existing UTs.