Writing Quality Code

We strive to write code that conforms to the 4 rules for developers by Sandi Metz:

  1. Classes can be no longer than one hundred lines of code.
  2. Methods can be no longer than five lines of code.
  3. Pass no more than four parameters into a method. Hash options are parameters.
  4. Controllers can instantiate only one object. Therefore, views should only know about one instance variable.

Please read an article on those 4 rules.

The 4th rule can be a handful to conform to. Whenever in doubt of breaking any rule generally, follow this:

  1. Don't violate a guideline without a good reason.
  2. A reason is good when you can convince a teammate.

Since it's often a handful, just note that the reason it's created is because of controller actions like this one.

Other guidelines

class Order
  def self.policy_class