2

I have read in books and heard at university that methods should not exceed one screen in length. Is there enough empirical evidence to support this hypothesis? Does it really make it easier to spot errors and fix them?

3 Answers3

4

A summary of research on the subject can be found at: http://dubroy.com/blog/method-length-are-short-methods-actually-worse/

3

A method should be as long as required to perform the task for which it is designed. No shorter and no longer.

DwB
  • 37,124
  • 11
  • 56
  • 82
2

The reason that I have been told this is that you can read the whole method without the need for scrolling and it fits onto the page. This is handy when reading the code becase you may wish to glance stuff at the top of the method.

As to evidence it is antldotal.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127