Clarify that private variables should not be prefixed with an underscore#52
Clarify that private variables should not be prefixed with an underscore#52MrPowers wants to merge 1 commit intodatabricks:masterfrom
Conversation
|
So this has been debated in the past and a lot of people with experience in Java / C++ are used to writing underscores. I personally don't have an issue with it. |
|
@rxin - I did some research on how some popular open source Scala projects name private variables.
Here are the commands I used to generate the counts:
Most private vals are not prefixed with underscores in the selected projects. I think a codebase should be consistent, pick one convention and stick with it. It seems like the Scala community generally favors not prefixing private variables, so I think my pull requests stands. I am open to your thoughts / comments. Thanks! |
|
The issue is that what is the convention for naming a private variable that has a public method with the same name? Prefix underscore is a very natural way to do this (even in other Scala projects). |
I agree with the majority of posters in this thread that private variables should not be prefixed with underscores.
In the Spark codebase, the majority of private variables are not prefixed with an underscore, but there are a lot of exceptions. Run
ack private\ val\ \_.Please provide some more guidance if I'm missing something (e.g. certain private variables should be prefixed with underscores and others should not). Thanks!