Skip to content
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

Editing the Doctrine section to improve accuracy and readability #6455

Closed
wants to merge 7 commits into from

Conversation

natechicago
Copy link
Contributor

The changes here add some important details to "Relationship Mapping Metadata" section. I've also reorganized it a little bit.

In this section, beginners are led through the process of associating products and categories. These entities are related in a many-to-one relationship. However, the documentation previously introduced the somewhat-confusing and optional information (the OneToMany mapping of a collection of product objects onto the category class) prior to introducing the more straight-forward and mandatory information (the ManyToOne mapping of a category object onto the product class).

The changes in this PR introduce the ManyToOne mapping before the OneToMany mapping, so that the overall flow of information is from the most important to the less important. The changes also make it explicitly clear that the OneToMany mapping is optional.

Q A
Doc fix? yes
New docs? no
Applies to 2.3
Fixed tickets n/a

@@ -916,8 +924,81 @@ a ``name`` field and the associated getter and setter functions.
Relationship Mapping Metadata
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt like a more-detailed explanation of the difference between OneToMany and ManyToOne was warranted here, since we're dealing with readers who may not be familiar with those terms (and who may be confused by the fact that both terms can be used to describe the same relationship).

Copy link
Member

Choose a reason for hiding this comment

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

I really like that you switched the order to show ManyToOne first. I wrote this original spot, but it's bothered me for a long time that we showed OneToMany first (I hadn't had a chance to change it).

@javiereguiluz
Copy link
Member

@natechicago thanks for this nice contribution and for making it not too long so we can fully review it. Thanks!

makes sense in the application for each ``Category`` to hold an array of
``Product`` objects.
Doctrine does not *require* that the "one" side of a one-to-many relationship
hold a collection of its "many" related entities. But in the context of our
Copy link
Member

Choose a reason for hiding this comment

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

holds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not to split hairs, but using the present subjunctive is grammatically appropriate here.

Copy link
Member

Choose a reason for hiding this comment

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

Why? The verb refers to the "the one side" subject of this sentence, doesn't it? And this is in its singular form.

We could also change it to "Doctrine does not require the "one" side of a one-to-many relationship to hold [...]". What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right that the subject here is "the one side" (3rd person, singular). However, the 3rd person singular conjugation of the verb "hold" in the present subjunctive is hold, not holds. http://www.verbix.com/webverbix/English/hold.html But since this has caused some unnecessary confusion, I'll change the phrasing per your second suggestion.

@@ -916,8 +924,81 @@ a ``name`` field and the associated getter and setter functions.
Relationship Mapping Metadata
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To relate the ``Category`` and ``Product`` entities, start by creating a
``products`` property on the ``Category`` class:
In our example, each category can be associated with *many* products, while
Copy link
Member

Choose a reason for hiding this comment

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

One last comment: In the docs we never used the first person perspective. So I would change this to "In this example, [...]".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Thanks for the thorough review on this PR!

@xabbuh
Copy link
Member

xabbuh commented Apr 25, 2016

@natechicago I just left one last minor comment. Other this looks really great to me. 👍

application, it makes sense for each ``Category`` object to hold a collection
of ``Product`` objects. However, if we had decided against adding a ``$products``
property to the ``Category`` class, then the ``Product`` entity's ``inversedBy``
metadata would have to be omitted.
Copy link
Member

Choose a reason for hiding this comment

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

This is the first spot where I've found your explanation and wording anything but wonderful. Here, the first sentence isn't completely clear (and as you mentioned, it's very important that we're clear). When you say "does not require" - it's not clear if the mapping is not required (this is what you meant) or if the mapping is required, but "holding a collection of its many related entities" is somehow the optional part.

This is a tricky spot: as it's a "choice", and it's not clear why I would make one choice or another. Let's recommend that they do make both sides of the relationship (as we're doing now), and make this more of a light note - e.g. btw, you don't have to map the OneToMany side, but if you're unsure, do 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.

I've tried to reword this a bit, but fear it may still be a little too clunky. Feel free to have at it yourself during the merge :)

@weaverryan
Copy link
Member

@natechicago I left a few comments for you. But this is AWESOME. Can you also read all the other pages on the docs? ;) You're making some changes (and more) that I've wanted to make for awhile. Very clear explanation in a spot that is commonly difficult for beginners.

@natechicago
Copy link
Contributor Author

@weaverryan Thanks for the feedback and encouragement!

@weaverryan
Copy link
Member

👍

@xabbuh
Copy link
Member

xabbuh commented May 9, 2016

Thank you @natechicago.

xabbuh added a commit that referenced this pull request May 9, 2016
…ability (natechicago)

This PR was squashed before being merged into the 2.3 branch (closes #6455).

Discussion
----------

Editing the Doctrine section to improve accuracy and readability

The changes here add some important details to "Relationship Mapping Metadata" section.  I've also reorganized it a little bit.

In this section, beginners are led through the process of associating products and categories.  These entities are related in a many-to-one relationship.  However, the documentation previously introduced the somewhat-confusing and *optional* information (the OneToMany mapping of a collection of product objects onto the category class) prior to introducing the more straight-forward and *mandatory* information (the ManyToOne mapping of a category object onto the product class).

The changes in this PR introduce the ManyToOne mapping before the OneToMany mapping, so that the overall flow of information is from the most important to the less important.  The changes also make it explicitly clear that the OneToMany mapping is optional.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.3
| Fixed tickets | n/a

Commits
-------

1e06da5 Editing the Doctrine section to improve accuracy and readability
@xabbuh xabbuh closed this May 9, 2016
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.

None yet

4 participants