Is there any research on ideal METHOD LENGTH?

爷,独闯天下 提交于 2020-01-15 05:15:35

问题


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?


回答1:


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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/7676091/is-there-any-research-on-ideal-method-length

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!