Video

Want to see the full-length video right now for free?

Notes

We've been writing Ruby for years on lots of different projects and in many different environments. This has led to thoughtbot's Ruby style to be somewhat different to the rest of the community's. In particular, we tend to focus on a sub-set of Ruby's features. Derek and Joël discuss some of those differences and the reasoning behind them.

Style guide: https://github.com/thoughtbot/guides

Testing

DSLs and OOP

Conditional logic

  • Use else
  • Don't really use unless
  • Avoid post-conditions
  • Avoid early returns
  • Guard clauses
  • Avoid ternaries
  • The "squint test"
  • Extract Method

Enumerable

Metaprogramming

  • Powerful set of tools
  • Can be a foot gun
  • Has its uses, tends not to be in app code
  • Combined with user-input is security risk
  • unused
  • Alternatives:
    • Normal programming
    • Object oriented composition
  • Design Patterns book

Verbosity

  • Individual classes and methods are shorter
  • More classes
  • Avoiding clever one-liners