-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Rename Parent
to ChildOf
and Children
to ParentOf
#17412
Comments
Parent
to ChildOf
.Parent
to ChildOf
and Children
to ParentOf
This is the |
When doing this, we should be sure to keep the old names around as deprecated type aliases for a cycle. |
I proposed in #17398 (comment) that each relationship actually have three names:
So for example, something like:
I didn't specify names for reactions because IMHO reactions don't need a special relation type: ownership is sufficient. |
I would prefer it if we didn't need to build special-cased constructors for these things:
Ex: If ParentOf is the component name, then it should also be the thing that we use during spawn. ParentOf is actually reasonable in this context: world.spawn((
Foo,
ParentOf::spawn((
Spawn(Bar),
Spawn(Baz),
)),
))
world.spawn((
Foo,
parent_of![
Bar,
Baz,
]
));
bsn! {(
Foo,
ParentOf [
Bar,
Baz,
]
)} (note that my current plan for BSN and If we do want to refer to the "collection of childof relationships" as "children" in this context, then we should violate our "IsA" constraint and just give it the name that makes us happy. Needing to connect ParentOf to a new "children" concept name is confusing and needlessly complicated. I don't think losing IsA here is a particular loss. It wouldn't be the first or the last case where "IsA" naming doesn't quite fit (as mentioned above). |
Just put out the rename PR. I left some more thoughts there (but lets discuss here):
|
One problem with depending on the "Of" and "By" suffixes is that they can point in opposite directions depending on the verb chosen:
This means you can't rely on the suffix alone to indicate the directionality of the relationship, you have to know the meaning of the word that describes the relationship in order to know the directionality. |
I hope this comment amounts to more than just bike shedding, but what about I removed the derives for brevity. /// A component that can store a reference to a list of unit entities.
pub struct UnitRefs(pub Vec<Entity>);
/// A component to store a list of references to the target entity that a
/// regiment is moving to.
pub struct MoveTargetRefs(pub Vec<Entity>);
/// A component that can store a reference to a regiment entity.
pub struct RegimentRef(pub Entity);
/// A component that can store a reference to a regiment's leader entity.
pub struct RegimentLeaderRef(pub Entity); Referring to the first updated example in #17427: mut interaction_query: Query<
(
&Interaction,
&mut BackgroundColor,
&mut BorderColor,
&ParentOf,
),
(Changed<Interaction>, With<Button>),
>, I don't know if it's just me, but I struggle to understand what "parent of" means here: It's hurts trying to work it out. I know I can work it out, but yeah it doesn't look obviously clear to me by reading the query alone. Replace it with mut interaction_query: Query<
(
&Interaction,
&mut BackgroundColor,
&mut BorderColor,
&ChildRefs,
),
(Changed<Interaction>, With<Button>),
>, Same with mut interaction_query: Query<(&Interaction, &ChildOf), (Changed<Interaction>, With<Button>)>, After, we now know we're asking for the reference to the parent: "Give me interaction entities and the ref to its parent" mut interaction_query: Query<(&Interaction, &ParentRef), (Changed<Interaction>, With<Button>)>, |
On one hand the English language already defines dedicated words for a number of relationships and rules to form words for new ones. On the other hand - as Cart pointed it out - it makes sense to specifically indicate the built-in-relationship nature of the components. This leaves the dedicated English words available to actual users (e.g. Whether this makes it weird to read the code is a different matter, but I think relationships need getting used to either way. Note: Flecs is also convoluted in this matter. It's just how relationship definitions fold out. |
I must say, the
Perhaps we could even add And next, if we want to go that route, we could add Bevy lints to check for common encouraged/discouraged patterns:
The only real downside I can see with this naming convention is that we already have the |
The |
I see your point. We could still apply the convention generally in the ecosystem, but then also have a type alias for Bevy-specific entity-reference-components that need better names for non-programmers. In the ECS code, people can then use |
The other challenge with a |
Indeed, I was thinking about that this morning: while there are a few cases of reciprocal nouns in English ("buyer" vs. "seller"), this only happens for the most common interpersonal relationships; most use the awkward "-ee" suffix such as "grantor" vs. "grantee" and so on. |
@alice-i-cecile Can you elaborate on what you mean and maybe given an example? It might be the case that the example |
Before the recent relations PR landed, the standard way to create custom relations was to only define a single component for them (analogous to Parent). Bevy 0.16's relationships need two components, one for each side of the relationship. Your names make sense in that context, but will be hard to migrate. Let's take We could also make the |
Ah ok this was the piece I was missing. That makes a lot of sense now. I guess there are probably a couple more reasons why the
|
I like this. The plural side of the relationship is less ambiguous than the single side. A single entity probably won't be mistaken for "a children." And the two names seem closely related. |
I kind of feel like there is no specific lintable naming pattern we can (or should) enforce, other than general guidelines for what the names should be describing. Relationships are essentially just a way to describe how an entity relates to another. In some cases, a noun followed by a possessive preposition like I really like As an aside, a use case of my own: I'm likely switching the |
Just a small observation: From what I understand, there previously were components which describe what an entity "is" or "has". So an entity can be a
So I was wondering, what if components are just named in what feels most intuitive, while avoiding confusion, with clear documentation or even a macro which describes how a component is supposed to be interpreted (could affect how an inspector displays the component), or even written (such as in a DSL)? Silly example: #[verb(is)]
struct Player(Team);
#[verb(has)]
struct Health(f32);
#[verb(does)]
struct Likes(Entity); As for the renaming itself, I would tend towards Wanted to throw my thoughts out there in case someone else more familiar found a use for them. |
Sounds like there is a reasonable amount of agreement to keep Children as-is and rename Parent to ChildOf. I've updated #17427, which I think should be good to merge now. |
Fixes #17412 ## Objective `Parent` uses the "has a X" naming convention. There is increasing sentiment that we should use the "is a X" naming convention for relationships (following #17398). This leaves `Children` as-is because there is prevailing sentiment that `Children` is clearer than `ParentOf` in many cases (especially when treating it like a collection). This renames `Parent` to `ChildOf`. This is just the implementation PR. To discuss the path forward, do so in #17412. ## Migration Guide - The `Parent` component has been renamed to `ChildOf`.
When I started learning how to use Bevy recently, this was the first stumbling block. It seemed straightforward that
Parent
was a marker component (or "driving concept") for a parent entity!Originally posted by @physgun in #17398 (comment)
The text was updated successfully, but these errors were encountered: