Sandi Metz - The Rules
30 Jun 2015Class can have no more than 100 lines
A method can contain no more than 5 lines
Can be passed no more than 4, more like 3 parameters
A controller action can only pass one instance variable
No more than 2 class names per controller action
Make smaller things and they should know as little about each other as possible
When looking at large chucks of code, its okay to do the "squint method" **1. Changes in shape means you have nested conditionals and it will be very hard to reason about
**2. Changes in color signify different levels of abstraction means that it be hard to follow
Duplication is far cheaper than the wrong abstraction
When code can know less, we can do more. Inheritance is okay when the subclasses - shallow, narrow hiearchry - subclasses to be at the leaf nodes of the object graph - subclasses use all the behavior of the superclass
Case Statements are made for business logic and not configuration - extract configuration into a hash.