Skip to content

Instantly share code, notes, and snippets.

@martensonbj
Last active March 18, 2016 17:20
Show Gist options
  • Save martensonbj/5843e2ec11423ade41a3 to your computer and use it in GitHub Desktop.
Save martensonbj/5843e2ec11423ade41a3 to your computer and use it in GitHub Desktop.
Review of Sandi Metz's 4 Rules For Developers

###Sandi Metz's Rules For Developers

Sandi Metz states four rules to maintain good code:

  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 can only know about one instance variable and views should only send messages to that object.

In my opinion, rule 2 is the most difficult to follow as a new developer. It is difficult to determine when a long method should be broken into smaller methods, especially if its because of a single if else statement. As I learn more about what good code is, my methods are getting progressively shorter. That being said, access to the breadth of knowledge necessary to know how to efficiently navigate around a problem is still a work in progress. It will be an interesting challenge to keep this rule in mind as I code through module 4 and challenge myself to find better ways to accomplish tasks.

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