Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Pull request Compare This branch is 3 commits ahead, 242 commits behind master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Best Practices

A guide for programming well.


Object-Oriented Design

  • Avoid global variables.
  • Avoid long parameter lists.
  • Limit collaborators of an object (entities an object depends on).
  • Limit an object's dependencies (entities that depend on an object).
  • Prefer composition over inheritance.
  • Prefer small methods. One line is best.
  • Prefer small objects with a single, well-defined responsibility.
  • Tell, don't ask.


  • Avoid optional parameters. Does the method do too much?
  • Avoid monkey-patching.
  • Prefer classes to modules when designing functionality that is shared by multiple models.
  • Prefer private when indicating scope. Use protected' only with comparison methods likedef ==(other),def <(other), anddef >(other)`.


  • Don't change a migration after it has been merged into master if the desired change can be solved with another migration.
  • Validate the associated belongs_to object (user), not the database column (user_id).


Background Jobs

  • Store IDs, not ActiveRecord objects for cleaner serialization, then re-find the ActiveRecord object in the perform method.



  • Disable real HTTP requests to external services with WebMock.disable_net_connect!.
  • Test background jobs with a Delayed::Job matcher.
  • Use a Fake to stub requests to external services.
  • Use integration tests to execute the entire app.
  • Use non-SUT methods in expectations when possible.


  • Don't support clients without Javascript.
  • Don't support IE6.
Something went wrong with that request. Please try again.