-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Consider using idiomatic capitalization in backend interface #11582
Comments
I'd like to reopen this for discussion It feels useful to have the Anki code which mirrors the python be 1:1 in all aspects. One of our constant maintenance tasks will be to match Anki Desktop's python, and we want this to be done as easily as possible. With Kotlin, we can get very close to matching the syntax of the python. Everything else: Absolutely go with idiomatic code. One of my long-term goals (once we're back to parity) would be linking the files to the Anki Desktop hashes so we ensure we don't miss changes going forwards. |
My thinking here is that most of the time, developers are not concerned with the intricacies of the backend, and they expect functions/properties to be in the format typical of that language. When developers do need to compare things to the desktop code, it's fairly easy to convert a camelCase name to a snake_case name in your head, and the conversion is unambiguous. Given that the desktop code is a mix of the formats itself (Rust/Python use snake_case; TypeScript uses camelCase; the protobuf definitions use PascalCase for methods, snake_case for properties, and SCREAMING_CASE for enum cases), I'm not sure you could even claim that one format is canonical. Presumably that's the view the protobuf developers took too - the generated Java/Kotlin code uses idiomatic casing instead of trying to match the protobuf definitions. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Conclusion:
camelCase should be used by default An annotation has been added |
DroidBackend is currently a mix of snake_case and camelCase names. Presumably the former was picked to more closely match the Python and Rust code, but I'd humbly suggest it would be better to use the more idiomatic camelCase, as that is less surprising, and will let you avoid editor warnings. Anki's TypeScript code uses camelCase too, as does the default codegen for protobuf files in Kotlin/Java.
The text was updated successfully, but these errors were encountered: