Max line count of one file? [closed]

流过昼夜 提交于 2020-01-24 22:13:32

问题


How many max number of lines of code one .cs file should hold. Are there any industry standards/best practices?


回答1:


I don't know how much, but there is a number which is considered a best practice.

It's all about maintainability, and there's much more to it than the number of lines in a source file. What about number of methods in a class? Cyclomatic complexity of a method? Number of classes in a project?

It's best to run a code metrics tool on your source code to find out more, like NDepend.




回答2:


As few as possible to do the job required whilst remaining readable.

If you're spilling over into the thousands upon thousands of line you might want to ask yourself what exactly this file is doing and how can you split it up to express the activity better.

Day to day, if I find a class which is more than 1000 lines long I am always suspicious that either the class is responsible for too much, or the responsibility is expressed badly.

However as with every rule of thumb, each case should be assessed on it's own merits.



来源:https://stackoverflow.com/questions/2680867/max-line-count-of-one-file

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