-
Notifications
You must be signed in to change notification settings - Fork 6
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
Upper case known acronyms in field/variable names #9
Comments
Well, here's the thing, those fields were named
Though it does seem that the Go stdlib has a different opinion on that (e.g. On the off chance that someone did something stupid and declared two fields on the same struct with the same name except that are case differences, I don't know how comfortable I feel about making that change. |
Haha! https://github.com/golang/go/wiki/CodeReviewComments#initialisms While this does agree with you for human code, it does exempt machine generated code:
|
I guess my argument boils down to we’ve already departed from the “true” field name and introduced a (small) collision risk to export the field in the first place (making the first letter uppercase/replacing invalid characters). So if we’re comfortable with that risk, why not make the name cleaner/more Go-like too (assuming we can do it with a extremely high degree of confidence/correctness). |
@PapaCharlie What about allowing a list of acronyms to be specified as an optional in the arguments/gradle file similar to |
That makes me feel even less comfortable! Now if I have a shared type that is used by two different resources that were generated with different settings, the shared type won't be compatible. IMO using the same code version should always yield the same code. But, I am slowly warming up to standardizing these things. Maybe any fields that aren't case-insensitive-unique we just slap on a |
I've been thinking about this some more though. What if I have a struct which only has one field: |
Currently go-restli converts names to variables/exported struct fields by simply uppercasing the first letter.
As some examples:
It would be nice if go-restli converted these names/fields to something a little more readable like
ExecutionUUID
orReviewBoardID
.This would require maintaining a list of known acronyms, for similar projects I've just maintained a list of known acronyms, ex:
While doing this would be nice for readability, I admit it does make any change to this list a major version bump of the library as existing clients would potentially need to migrate their struct fields. Thoughts on if this should be done?
At a high level the logic would be to split the string by each uppercase letter into a slice (ex:
"reviewBoardId"
becomes[]string{"review", "Board", "Id"}
then compare each slice member with the replacement list swapping as needed.The text was updated successfully, but these errors were encountered: