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

velocityXYZ names are violating conventions #459

Closed
ix0rai opened this issue Jul 2, 2023 · 5 comments
Closed

velocityXYZ names are violating conventions #459

ix0rai opened this issue Jul 2, 2023 · 5 comments
Assignees
Labels
s: medium PRs with less than 700 lines and more than 200 t: refactor proposes a refactor

Comments

@ix0rai
Copy link
Member

ix0rai commented Jul 2, 2023

as discussed in this pr and on discord, velocityXYZ reads much less naturally than xyzVelocity, which means that velocityXYZ names are in violation of the conventions, specifically this section of "general":

To make code as easy to read as possible, keep names in the natural language order. For example, a class representing a chest block entity should be named ChestBlockEntity rather than BlockEntityChest. Though prefix naming may be helpful for grouping classes together in an IDE's tree view, reading and writing code is done much more often than browsing files.

@ix0rai ix0rai added t: refactor proposes a refactor s: medium PRs with less than 700 lines and more than 200 labels Jul 2, 2023
@ix0rai ix0rai self-assigned this Jul 2, 2023
@ix0rai
Copy link
Member Author

ix0rai commented Jul 2, 2023

additionally, seeing how common this mistake is, we should add this as an example in the conventions.

@supersaiyansubtlety
Copy link
Contributor

Re-posting what I said on discord:

iiuc its
"velocity's x component" for velocityX
vs
"x component of velocity" for xVelocity
imo both are pretty natural, so no reason to change it

Additionally, this would contradict the Coordinates convention, which goes so far as to specify "velocityX, not xVelocity"

Coordinates can be named x, y, and z when it's clear what they represent. If clarification is needed, add a word in front of the coordinate (velocityX, not xVelocity).

When this was brought up on discord it seemed like there was a distinct lack of agreement that the current "velocityX" order is less natural.

There was also disagreement on the current "velocityX" being less natural in #458 where, to my knowledge, this discussion started. Start of discussion.

@Antikyth
Copy link
Contributor

Antikyth commented Sep 6, 2023

I agree with @supersaiyansubtlety that velocityXYZ is a better word order. However, does it make more sense for it to be velocityXyz? I think probably not, it just depends on whether you want to treat it like an acronym (which it isn't) or not:

Treat acronyms as single words rather than capitalizing every letter. This improves readability (compare JsonObject and JSONObject) and it's consistent with Mojang naming (a known name is NbtIo).

@supersaiyansubtlety
Copy link
Contributor

The issue is actually about velocityX, velocityY, and velocityZ.
velocityXYZ is just shorthand to talk about all 3.

@ix0rai
Copy link
Member Author

ix0rai commented Sep 7, 2023

I'm not sure I support this change anymore, but if anyone has another argument for it I'd love to hear it. otherwise, I'm closing the issue.

@ix0rai ix0rai closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: medium PRs with less than 700 lines and more than 200 t: refactor proposes a refactor
Projects
None yet
Development

No branches or pull requests

3 participants