Skip to content

Instantly share code, notes, and snippets.

@brantwellman
Last active March 17, 2016 00:33
Show Gist options
  • Save brantwellman/cc0e53736e1697a47f4b to your computer and use it in GitHub Desktop.
Save brantwellman/cc0e53736e1697a47f4b to your computer and use it in GitHub Desktop.
Metz's 4 rules for developers and comments
  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.

I've run into each one of these issues without knowing about these rules, and I've actually dealt with each one at one point or another, but not neceassarily knowing it why each time.

1 - is a sign that your class is doing too many things, and I think that I am much better at recognizing this issue now.
2 - is something that I have struggeled with. I have gotten better at defining private methods to pull excessive code out of a method, however keeping a method to a basic if/else statement with no additional code seems excessively difficult. I think there may be times where I struggle to properly group and pull out enough code to keep a controller method that simple.
3 - I don't think I've ever passed more than 3 parameters into a method. At this time, I don't see this being a problem.
4 - I've begun using presenter objects over the last couple of project and see the value of them in keeping code much more readable.

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