Skip to content

[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

Merged
merged 1 commit into from
Sep 5, 2015

Conversation

zerustech
Copy link
Contributor

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.

  • 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 DiffOperation should 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) = target
  • new = all ∖ source = {x: x ∈ target ∧ x ∉ source}
  • 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

@zerustech
Copy link
Contributor Author

@stof @aitboudad Please check, thanks.

@zerustech zerustech force-pushed the translation-catalogue-operation branch 5 times, most recently from dd0908f to ba1311a Compare August 17, 2015 14:17
* obsolete = source ∖ all = source ∖ target = {x: x ∈ source ∧ x ∉ target}
* Basically, the result contains messages from the target catalogue.
*
* @author Jean-François Simon <contact@jfsimon.fr>
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Contributor Author

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

@zerustech zerustech force-pushed the translation-catalogue-operation branch from ba1311a to 5a1755e Compare August 25, 2015 12:27
@aitboudad
Copy link
Contributor

@zerustech
Copy link
Contributor Author

@aitboudad Shall I create a separate PR for it after this PR is merged or just include the change in this PR?

@aitboudad
Copy link
Contributor

just include the change

@zerustech zerustech force-pushed the translation-catalogue-operation branch from 5a1755e to 316277e Compare August 25, 2015 14:30
@zerustech
Copy link
Contributor Author

@aitboudad Updated

@aitboudad
Copy link
Contributor

👍

@aitboudad
Copy link
Contributor

ping @symfony/deciders

@@ -15,6 +15,9 @@
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\MessageCatalogueInterface;

/**
* @group legacy
*/
class DiffOperationTest extends AbstractOperationTest
Copy link
Member

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?

@zerustech zerustech force-pushed the translation-catalogue-operation branch from 316277e to 5d59c8e Compare September 1, 2015 03:24
@zerustech
Copy link
Contributor Author

@xabbuh @stof Updated

@zerustech zerustech force-pushed the translation-catalogue-operation branch from 5d59c8e to 4f65a86 Compare September 1, 2015 03:26
@xabbuh
Copy link
Member

xabbuh commented Sep 1, 2015

Looks like you need to bump the required version of the Translation component in the FrameworkBundle.

@zerustech zerustech force-pushed the translation-catalogue-operation branch from 4f65a86 to 966b455 Compare September 1, 2015 07:06
@zerustech
Copy link
Contributor Author

@xabbuh Updated

use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
use Symfony\Component\Filesystem\Filesystem;

class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
Copy link
Contributor

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

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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)

Copy link
Contributor Author

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?

Copy link
Member

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...

Copy link
Contributor Author

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 is 2.3, but in the future if 2.3 is not supported any more,
    the branch might be 2.7 for example.
  • Add the test script in that branch

Is that correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

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.

@aitboudad aitboudad removed the Ready label Sep 2, 2015
use Symfony\Component\Translation\Catalogue\TargetOperation;
use Symfony\Component\Translation\MessageCatalogueInterface;

class TargetOperationTest extends DiffOperationTest
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh Fixed

@zerustech zerustech force-pushed the translation-catalogue-operation branch from 966b455 to 5ef5a05 Compare September 3, 2015 06:38
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 &#x2229; target = {x: x &#x2208; source &#x2227; x &#x2208; target}
* [x] ``all`` = **result of the operation, depends on the operation.**
* [x] ``new`` = all &#x2216; source = {x: x &#x2208; all &#x2227; x &#x2209; source}
* [x] ``obsolete`` = source &#x2216; all = {x: x &#x2208; source &#x2227; x &#x2209; all}

The following analysis explains why ``DiffOperation`` should be deprecated.

* [x] ``all`` = source &#x222a; target = {x: x &#x2208; source &#x2228; x &#x2208; target}
* [x] ``new`` = all &#x2216; source = {x: x &#x2208; target &#x2227; &#x2209; source}
* [x] ``obsolete`` = source &#x2216; all = {x: x &#x2208; source &#x2227; x &#x2209; source &#x2227; x &#x2209; target} = &#x2205;

This absolutely makes sense.

* [ ] ``all`` =  intersection &#x222a; (target &#x2216; intersection) = target
* [x] ``new`` = all &#x2216; source = {x: x &#x2208; target &#x2227; x &#x2209; source}
* [x] ``obsolete`` = source &#x2216; all = source &#x2216; target = {x: x &#x2208; source &#x2227; x &#x2209; target}

The ``all`` part is confusing because 'diff' should either mean 'relative complement' or 'symmetric difference' operation:

* ``all`` = source &#x2216; target = {x: x &#x2208; source &#x2227; x &#x2209; target}

* ``all`` = (source &#x2216; target) &#x222a; (target &#x2216; source) = {x: x &#x2208; source &#x2227; x &#x2209; target &#x2228; x &#x2208; target &#x2227; x &#x2209; source}

* ``all`` =  intersection &#x222a; (target &#x2216; 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
@zerustech zerustech force-pushed the translation-catalogue-operation branch from 5ef5a05 to 353c94d Compare September 3, 2015 06:50
zerustech added a commit to zerustech/symfony that referenced this pull request Sep 3, 2015
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
zerustech added a commit to zerustech/symfony that referenced this pull request Sep 3, 2015
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
@aitboudad aitboudad added the Ready label Sep 3, 2015
@xabbuh
Copy link
Member

xabbuh commented Sep 5, 2015

👍

@aitboudad
Copy link
Contributor

Thank you @zerustech.

@aitboudad aitboudad merged commit 353c94d into symfony:2.8 Sep 5, 2015
aitboudad added a commit that referenced this pull request Sep 5, 2015
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 &#x2229; target = {x: x &#x2208; source &#x2227; x &#x2208; target}
* [x] ``all`` = **result of the operation, depends on the operation.**
* [x] ``new`` = all &#x2216; source = {x: x &#x2208; all &#x2227; x &#x2209; source}
* [x] ``obsolete`` = source &#x2216; all = {x: x &#x2208; source &#x2227; x &#x2209; all}

The following analysis explains why ``DiffOperation`` should be deprecated.

## Logic of ``MergeOperation``:
* [x] ``all`` = source &#x222a; target = {x: x &#x2208; source &#x2228; x &#x2208; target}
* [x] ``new`` = all &#x2216; source = {x: x &#x2208; target &#x2227; &#x2209; source}
* [x] ``obsolete`` = source &#x2216; all = {x: x &#x2208; source &#x2227; x &#x2209; source &#x2227; x &#x2209; target} = &#x2205;

This absolutely makes sense.

## Logic of ``DiffOperation``:
* [ ] ``all`` =  intersection &#x222a; (target &#x2216; intersection) = target
* [x] ``new`` = all &#x2216; source = {x: x &#x2208; target &#x2227; x &#x2209; source}
* [x] ``obsolete`` = source &#x2216; all = source &#x2216; target = {x: x &#x2208; source &#x2227; x &#x2209; target}

The ``all`` part is confusing because 'diff' should either mean 'relative complement' or 'symmetric difference' operation:

### Relative Complement:
* ``all`` = source &#x2216; target = {x: x &#x2208; source &#x2227; x &#x2209; target}

### Symmetric Difference:
* ``all`` = (source &#x2216; target) &#x222a; (target &#x2216; source) = {x: x &#x2208; source &#x2227; x &#x2209; target &#x2228; x &#x2208; target &#x2227; x &#x2209; source}

### Current Logic has Nothing to do with "Diff":
* ``all`` =  intersection &#x222a; (target &#x2216; 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
@zerustech
Copy link
Contributor Author

@aitboudad No problem.

fabpot added a commit that referenced this pull request Sep 14, 2015
… (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
@fabpot fabpot mentioned this pull request Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants