-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[translation] Deprecated DiffOperation #15562
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
[translation] Deprecated DiffOperation #15562
Conversation
|
@stof @aitboudad Please check, thanks. |
dd0908f to
ba1311a
Compare
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.
if you create this class and it is new, is it correct to copy the author?
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.
YEs, author indicates who created the code. This way, you know who to ask for if you're really stuck with a bit of code. That's why I propose to remvoe some of the added @author tags (for instance, from the deprecated class), as the current PR doesn't add much to 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.
@OskarStark I copied the author tags because I didn't change the code at all, I just copied the original code from the deprecated class.
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.
@wouterj I added myself as an additional author because I added detailed comments for these classes. They were a bit confusing before and it takes time to figure out the correct meanings of the classes as well as their properties.
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.
@zerustech @author is mostly useful for the author of the code, as explained by @wouterj. Adding only comments does not really need to be added as @author (these annotations are not a way to track all contributors to the class. This is what the git history is for)
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.
@stof I've updated the @author tags
ba1311a to
5a1755e
Compare
|
@aitboudad Shall I create a separate PR for it after this PR is merged or just include the change in this PR? |
|
just include the change |
5a1755e to
316277e
Compare
|
@aitboudad Updated |
|
👍 |
|
ping @symfony/deciders |
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.
What about extending the TargetOperationTest class instead and overriding only the createOperation method instead?
316277e to
5d59c8e
Compare
5d59c8e to
4f65a86
Compare
|
Looks like you need to bump the required version of the Translation component in the FrameworkBundle. |
4f65a86 to
966b455
Compare
|
@xabbuh Updated |
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 should be added in 2.3
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.
Testing the command is indeed a different topic and should go in a separate PR in 2.3
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.
@aitboudad @stof I've created PR #15673 as per your suggestion. However, if test script is added in a separate PR, how to prove the issue (and avoiding regressions) in this PR? And why should it be added in 2.3?
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.
@zerustech because testing the command makes sense in all versions of Symfony, and so it should be added first in 2.3 (which will then be merged into newer branches)
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.
@stof I agree with you, but why other test scripts like TranslationDebugCommandTest.php was not added in 2.3?
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.
because the TranslationDebugCommand does not exist in 2.3, and so cannot be tested there...
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.
@stof So just to clarify the workflow for adding a new test script:
- Find the oldest supported branch that contains the file to be tested.
In this case, the branch is2.3, but in the future if2.3is not supported any more,
the branch might be2.7for example. - Add the test script in that branch
Is that correct?
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.
yes
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.
@stof Thanks, I will follow it in the future.
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.
Inheritance should be the other way around. Otherwise, the new TargetOperationTest is a legacy test too.
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.
@xabbuh Fixed
966b455 to
5ef5a05
Compare
The ``DiffOperation`` class has been deprecated and ``TargetOperation``
should be used instead, because ``DiffOperation`` has nothing to do
with 'diff', thus its class name is misleading.
Also added detailed documents for all operation interface and classes.
The following names should have consistent meanings for all operations:
The name of ``intersection`` is temporarily introduced here to explain this issue.
* [x] ``intersection`` = source ∩ target = {x: x ∈ source ∧ x ∈ target}
* [x] ``all`` = **result of the operation, depends on the operation.**
* [x] ``new`` = all ∖ source = {x: x ∈ all ∧ x ∉ source}
* [x] ``obsolete`` = source ∖ all = {x: x ∈ source ∧ x ∉ all}
The following analysis explains why ``DiffOperation`` should be deprecated.
* [x] ``all`` = source ∪ target = {x: x ∈ source ∨ x ∈ target}
* [x] ``new`` = all ∖ source = {x: x ∈ target ∧ ∉ source}
* [x] ``obsolete`` = source ∖ all = {x: x ∈ source ∧ x ∉ source ∧ x ∉ target} = ∅
This absolutely makes sense.
* [ ] ``all`` = intersection ∪ (target ∖ intersection) = target
* [x] ``new`` = all ∖ source = {x: x ∈ target ∧ x ∉ source}
* [x] ``obsolete`` = source ∖ all = source ∖ target = {x: x ∈ source ∧ x ∉ target}
The ``all`` part is confusing because 'diff' should either mean 'relative complement' or 'symmetric difference' operation:
* ``all`` = source ∖ target = {x: x ∈ source ∧ x ∉ target}
* ``all`` = (source ∖ target) ∪ (target ∖ source) = {x: x ∈ source ∧ x ∉ target ∨ x ∈ target ∧ x ∉ source}
* ``all`` = intersection ∪ (target ∖ intersection) = target
So the name of ``DiffOperation`` is misleading and inappropriate.
Unfortunately, there is no corresponding set operation for this class,
so it's hard to give it an apppriate name.
From my point of view, I believe the most accurate name for this class
should be ``TargetOperation`` because its result is same as the target set.
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
5ef5a05 to
353c94d
Compare
Added the test script as per the discussion in PR symfony#15562 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a
Added the test script as per the discussion in PR symfony#15562 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a
|
👍 |
|
Thank you @zerustech. |
This PR was merged into the 2.8 branch.
Discussion
----------
[translation] Deprecated DiffOperation
## Summary:
The ``DiffOperation`` class has been deprecated and ``TargetOperation``
should be used instead, because ``DiffOperation`` has nothing to do
with 'diff', thus its class name is misleading.
Also added detailed documents for all operation interface and classes.
## Background:
The following names should have consistent meanings for all operations:
The name of ``intersection`` is temporarily introduced here to explain this issue.
* [x] ``intersection`` = source ∩ target = {x: x ∈ source ∧ x ∈ target}
* [x] ``all`` = **result of the operation, depends on the operation.**
* [x] ``new`` = all ∖ source = {x: x ∈ all ∧ x ∉ source}
* [x] ``obsolete`` = source ∖ all = {x: x ∈ source ∧ x ∉ all}
The following analysis explains why ``DiffOperation`` should be deprecated.
## Logic of ``MergeOperation``:
* [x] ``all`` = source ∪ target = {x: x ∈ source ∨ x ∈ target}
* [x] ``new`` = all ∖ source = {x: x ∈ target ∧ ∉ source}
* [x] ``obsolete`` = source ∖ all = {x: x ∈ source ∧ x ∉ source ∧ x ∉ target} = ∅
This absolutely makes sense.
## Logic of ``DiffOperation``:
* [ ] ``all`` = intersection ∪ (target ∖ intersection) = target
* [x] ``new`` = all ∖ source = {x: x ∈ target ∧ x ∉ source}
* [x] ``obsolete`` = source ∖ all = source ∖ target = {x: x ∈ source ∧ x ∉ target}
The ``all`` part is confusing because 'diff' should either mean 'relative complement' or 'symmetric difference' operation:
### Relative Complement:
* ``all`` = source ∖ target = {x: x ∈ source ∧ x ∉ target}
### Symmetric Difference:
* ``all`` = (source ∖ target) ∪ (target ∖ source) = {x: x ∈ source ∧ x ∉ target ∨ x ∈ target ∧ x ∉ source}
### Current Logic has Nothing to do with "Diff":
* ``all`` = intersection ∪ (target ∖ intersection) = target
So the name of ``DiffOperation`` is misleading and inappropriate.
Unfortunately, there is no corresponding set operation for this class,
so it's hard to give it an apppriate name.
From my point of view, I believe the most accurate name for this class
should be ``TargetOperation`` because its result is same as the target set.
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
353c94d [translation][framework-bundle] Deprecated DiffOperation
|
@aitboudad No problem. |
… (zerustech) This PR was merged into the 2.3 branch. Discussion ---------- [framework-bundle] Add Test for TranslationUpdateCommand Added the test script as per the discussion in PR #15562 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 232f6fd [framework-bundle] Add Test for TranslationUpdateCommand
Summary:
The
DiffOperationclass has been deprecated andTargetOperationshould be used instead, because
DiffOperationhas nothing to dowith 'diff', thus its class name is misleading.
Also added detailed documents for all operation interface and classes.
Background:
The following names should have consistent meanings for all operations:
The name of
intersectionis temporarily introduced here to explain this issue.intersection= source ∩ target = {x: x ∈ source ∧ x ∈ target}all= result of the operation, depends on the operation.new= all ∖ source = {x: x ∈ all ∧ x ∉ source}obsolete= source ∖ all = {x: x ∈ source ∧ x ∉ all}The following analysis explains why
DiffOperationshould be deprecated.Logic of
MergeOperation:all= source ∪ target = {x: x ∈ source ∨ x ∈ target}new= all ∖ source = {x: x ∈ target ∧ ∉ source}obsolete= source ∖ all = {x: x ∈ source ∧ x ∉ source ∧ x ∉ target} = ∅This absolutely makes sense.
Logic of
DiffOperation:all= intersection ∪ (target ∖ intersection) = targetnew= all ∖ source = {x: x ∈ target ∧ x ∉ source}obsolete= source ∖ all = source ∖ target = {x: x ∈ source ∧ x ∉ target}The
allpart is confusing because 'diff' should either mean 'relative complement' or 'symmetric difference' operation:Relative Complement:
all= source ∖ target = {x: x ∈ source ∧ x ∉ target}Symmetric Difference:
all= (source ∖ target) ∪ (target ∖ source) = {x: x ∈ source ∧ x ∉ target ∨ x ∈ target ∧ x ∉ source}Current Logic has Nothing to do with "Diff":
all= intersection ∪ (target ∖ intersection) = targetSo the name of
DiffOperationis misleading and inappropriate.Unfortunately, there is no corresponding set operation for this class,
so it's hard to give it an apppriate name.
From my point of view, I believe the most accurate name for this class
should be
TargetOperationbecause its result is same as the target set.