Is there a recommended number of lines of code per file?

I have a class file that contains all the classes needed for a specific web application. I am currently on line 7269 and contains many classes. This doesn’t bother me much, but I began to notice that Visual Studio reacts more slowly when working on this file. I think this may be caused by the file size and recompilation of Visual Studio after each press of the enter key.

Does anyone have any recommendations on line restrictions in the class file for each file, or maybe recommendations on how / why I should move classes to separate files?

I found this in relation to Java, but I am specifically associated with VB and Visual Studio 2005

Maximum lines of code allowed in a Java class?

thanks

EDIT There are about 50+ classes in the file, some small, some large!

+3
source share
6 answers

Egad.

It is highly recommended to everyone that classes are contained in a file for each class.

The lines are not very relevant directly, but this may be a sign that you are creating a too complex class of gods and need a break in logic. Unit test guided development makes it do it right.

edit (noticed "why?"):

from what you ask should be obvious :)

Several (for many reasons):

  • it is very difficult to visualize the actual code layout in large files

  • most IDEs are configured by default to display multiple files at once, but not for multiple views of the same file

  • : " {godfile}, ?"

  • //

+17

- , . : , (, Delegates.cs #) - , . , .

, .

- , 1000 - . , , . , , ( , )...

, - , " " .

+6

1 , 1 , .

, .

... , , , ? , , , , .

, . , - ?

0
0

. 200 ( ), .

, , !

0

, 1 . , , , 600 .

unittest , 3k-4k . . , ReSharper (ReSharper 2k VS).

0

All Articles