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

Reorganize Events and EventSequence code #9306

Merged
merged 3 commits into from
Aug 28, 2023

Conversation

Selene-Amanita
Copy link
Member

@Selene-Amanita Selene-Amanita commented Jul 30, 2023

Objective

Make code relating to event more readable.

Currently the impl block of Events is split in two, and the big part of its implementations are put at the end of the file, far from the definition of the struct.

Solution

  • Move and merge the impl blocks of Events next to its definition.
  • Move the EventSequence definition and implementations before the Events, because they're pretty trivial and help understand how Events work, rather than being buried bellow Events.

I separated those two steps in two commits to not be too confusing. I didn't modify any code of documentation. I want to do a second PR with such modifications after this one is merged.

@Selene-Amanita Selene-Amanita added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change labels Jul 30, 2023
@JoJoJet
Copy link
Member

JoJoJet commented Jul 31, 2023

I agree with merging the impl blocks and placing them next to the struct -- however I'd prefer for EventSequence to be defined under Events. In general, I think it's nice for a source file to read like a table of contents. When reading, first you see how something is used, then later on you see how it's defined. I find that this style makes it easier to understand the "why" of code since you see the context for a type before its implementation details.

Copy link
Member

@JoJoJet JoJoJet left a comment

Choose a reason for hiding this comment

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

Thanks for taking my advice! This file is much easier to read without the impl block split for no reason.

Marking as ready for final review, since this is a trivial change.

@JoJoJet JoJoJet added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 18, 2023
@Selene-Amanita
Copy link
Member Author

Thank you for reviewing ^^

Part of the reason I split the two changes in two commits is so I can easily revert the second one as I knew it wouldn't necessarily win unanimous support. I'm aware the convention is to see how something is used first then how it's implemented, but I thought for this case since it's so small and doesn't really have a use in itself, and the thing that use it is pretty big, it could make sense to put it before, but yeah I think it doesn't matter and you're right.

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 28, 2023
Merged via the queue into bevyengine:main with commit f38549c Aug 28, 2023
20 of 21 checks passed
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

Make code relating to event more readable.

Currently the `impl` block of `Events` is split in two, and the big part
of its implementations are put at the end of the file, far from the
definition of the `struct`.

## Solution

- Move and merge the `impl` blocks of `Events` next to its definition.
- Move the `EventSequence` definition and implementations before the
`Events`, because they're pretty trivial and help understand how
`Events` work, rather than being buried bellow `Events`.

I separated those two steps in two commits to not be too confusing. I
didn't modify any code of documentation. I want to do a second PR with
such modifications after this one is merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants