VeruGHub / easyclimate

Easy access to high-resolution daily climate data for Europe
https://verughub.github.io/easyclimate/
GNU General Public License v3.0
45 stars 1 forks source link

Algunos detalles a tener en cuenta #3

Closed Julenasti closed 3 years ago

Julenasti commented 3 years ago

Hola, @VeruGHub ya te pase este libro (https://r4ds.had.co.nz/) pero te resumo aqui algunos detalles que creo que merece la pena dedicarles un poco de tiempo ya que no cuesta mucho y lugo se agradece:

  1. function names should be verbs and arguments should be nouns. noun are OK if the function computes a very well known noun (i.e. mean())
  2. if a function name is composed of multiple words use snake_case, where each lowercase word is separated by an underscore. camelCase is OK too but be consistent!
  3. if you have a family of functions that do similar things, make sure they have consistent names and arguments. Use common prefix to indicate that they are connected (e.g. stringr in tidyverse)
  4. avoid the most common names from base R
  5. explain the why of your code. why did you choose that approach? (try this shortcut: ctrl+shift+r ;)
  6. both if and function should always be followed by {} and the contents should be indented by two spaces
  7. an opening curly brace should never go on its own line and should always be followed by a new line. A closing curly brace should always go on its own line, unless it's followed by else.
  8. generally data arguments should come first. Detail arguments should go on the end, and usually should have default values. the default value should be the most common value
  9. USE WHITESPACE AROUND IN FUNCTION CALLS AND ALWAYS PUT A SPACE AFTER A COMMA LIKE IN REGULAR ENGLISH (ayuda muchisimo siempre digas lo que digas, jaja)
  10. for arguments names use descriptive names except they are very well-known (e.g. df) and try to match names of existing R functions (e.g. na.rm)
  11. it's good practice to check important preconditions and throw and error (with stop()) if they are not true. But do this in the very important ones if not you will have a super long code. see stopifnot() function
VeruGHub commented 3 years ago

Revisa el código ahora y verás como te hago caso :P