What "case" to choose #92
Replies: 3 comments 5 replies
-
Can we just go with the tidyverse style? I just look at Google's R Style Guide and would be on board with those few differences from tidyverse except perhaps camel case for functions. If your point was to choose a naming convention within any given package/repository, where the convention choice would be up to the lead author/maintainer, that's fine with me too. |
Beta Was this translation helpful? Give feedback.
-
Sorry, my comment "choose a naming convention and stick to it" was meant more for individuals rather than a convention as a team. I just created this post to bring awareness about some of the different options that are out there, I had never seen a definition for SCREAMING_SNAKE_CASE before. The bullets under "Conclusions" are things that I plan on trying to adopt in all code that I write. I am a known violator of the last two bullets in many instances ❌ 🤕 |
Beta Was this translation helpful? Give feedback.
-
I got a big kick out of the Allison Horst graphic and also had never heard of SCREAMING_SNAKE_CASE (which hurts my eyes). As a team, we have made some efforts in the past to come up with a coding style, but I'm fine not trying to actually reach consensus on anything because it's not like the style police are going to get called if one of us doesn't follow what we agree on.
|
Beta Was this translation helpful? Give feedback.
-
We have all heard the term snake case and camel case; but, did you know there are other cases out there? Today, I just learned about SCREAMING_SNAKE_CASE, which is like snake_case but every letter is upper case. Here is a list of the different cases available and a beautiful infographic from @allison_horst, https://www.allisonhorst.com, showcasing a few of them.
There is little to no consistency or requirements for choosing which case to use, especially in R. Java and Kotlin, which have a C and C++ heritage, use camel case for variables and methods and upper camel case for reference types such as enums, classes, and interfaces. In Ruby and Python, SCREAMING_SNAKE_CASE is used for constants.
In R, there are very few hard and fast rules. But, there are some recommendations, largely from tidyverse's Style Guide, Advanced R by Hadley Wickham, and Google’s R Style Guide, where the latter is now based largely on the tidyverse guide itself.
Conclusions for programming in R within pfmc-assessments
plot
because base R has a function already namedplot()
Beta Was this translation helpful? Give feedback.
All reactions