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

Update Coding Conventions to match Compose conventions #4154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edrd-f
Copy link

@edrd-f edrd-f commented Apr 25, 2024

While discussing on Slack, there was an overall consensus that the current SCREAMING_SNAKE_CASE convention is inconsistent for a few reasons:

  1. It shouts at the readers and calls their attention first thing for things that shouldn't get more attention than other parts of the code. Enums, singletons, and constants do not hold any special characteristic that would require the reader to inspect the value of the variable or where it's being used. They don't represent unsafe, sensitive, or experimental code*.
  2. Compose, along with most of their plugins, libraries, and extensions, use the PascalCase convention. They have their own convention and reasoning for it written down here.
    • Given that Compose is one of the most-used frameworks, it fragments the community towards either their or Kotlin's official convention, which is bad.
  3. Having either PascalCase and SCREAMING_SNAKE_CASE allowed for enums isn't a good convention because it allows developers to make individual decisions on which style to pick and leads the project to a mixed (or no?) convention (Ktor's public enums are an example), defeating the purpose of a convention, which is to standardize the way developers write code and eliminate bike-shedding.

Given that Kotlin 2.0 is about to be released, this is the perfect time to make this change, and the community, as well as some JetBrains team members, have voted in favor of this change. I will be linking the PR on the Slack thread so the community and the Kotlin team are up-to-date and can add feedback.


* On a side note, the current convention is likely inherited from Java, which in turn inherited it from the C/C++ convention for macros, as they were used for constants. However, macros indeed require more attention because of arbitrary code expansion, so the shouting makes sense.

@edrd-f edrd-f requested a review from a team as a code owner April 25, 2024 00:13
@brighthr-stanton
Copy link

I'm really in favour of this. Pascal case is much more readable.

Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 26, 2024
@edrd-f
Copy link
Author

edrd-f commented May 27, 2024

Update: the proposal got a green light from the Kotlin team (see the Slack thread), but the migration process to the new convention still needs to be figured out.

@koshachy koshachy removed the Stale label May 27, 2024
@koshachy koshachy self-assigned this May 31, 2024
@koshachy koshachy force-pushed the edrd-f/code-conventions-update branch from bd5bedf to 04d16ba Compare May 31, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants