Skip to content

Instantly share code, notes, and snippets.

@SteveOscar
Created March 16, 2016 14:55
Show Gist options
  • Save SteveOscar/4871c15f5fc6e5709328 to your computer and use it in GitHub Desktop.
Save SteveOscar/4871c15f5fc6e5709328 to your computer and use it in GitHub Desktop.
Sandi Metz' 5 rules

#####Only instantiate one object in the controller.

This rule was the most interesting to me, and the one I initially mentally rejected, as it seems like it would often be impractical. But after looking further at how the implemented it, by creating a dashboard PORO with different methods to access multiple types of information, it is an interesting setup.

#####Each method should only have 5 lines.
About the 5-line methods rule - ff course in general it's good to keep methods as short and simple as possible, but I think that trying to squeeze every method into this rule will result in a lot of unreadable code using dense ternary statements, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment