Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby On Rails coding conventions, standards and best practices

Ruby On Rails coding conventions, standards and best practices


David Paluy

August 22, 2012


  1. Ruby On Rails coding conventions, standards and best practices David

    Paluy August 2012
  2. Philosophy (from Rails) • DRY – Don't Repeat Yourself •

    Convention over Configuration • YAGNI - You ain't gonna need it
  3. Source code Style • Two spaces, no tabs • Boolean

    tests: don't use “and” and “or”, always use “&&” and “| |”
  4. Go Easy on the Comments • If it's obvious –

    don't explain it • Remove old commented code • “How to” comments
  5. Camels for Classes, Snakes Everywhere Else • “Snake case”: lowercasse_words_separated_by_underscore

    • “Camel case”: ClassName good Class_name bad • Constants: (my own preference) ALL_UPPERCASE = true
  6. Parentheses (Optional)

  7. Parentheses (Do & Don't)

  8. Folding Up Lines

  9. Folding Up Blocks

  10. if vs unless

  11. while vs until

  12. Use Modifier Forms

  13. each, NOT for

  14. In the Wild

  15. Use Symbols to Stand for Something

  16. Composing Methods for Humans

  17. Make the code a little more articulate

  18. Readable Code

  19. Readable code makes your classes easier to test

  20. Git the diff says what you did; your commit message

    should tell me why you did this
  21. Summary Good code is like a good joke: It needs

    no explanation
  22. Credentials