开发者

Max line count of one file? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 2 years ago.

开发者_如何学Go Improve this question

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜