tags:

views:

116

answers:

3

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

A: 

as much as you can write....

prashant
the question was: what's the best practice, not the technical limitation
Gerrie Schenck
you know better how much you can handle on a single file...
prashant
It's not about how much you can handle. It's about how much the next person to read your code can handle. Even if that next person is you in 2 years.
cHao
+2  A: 

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.

Gerrie Schenck
A: 

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.

runrunraygun