Alex Rivera | Logout

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

Asked 2008-12-17T11:23:04.347
13

I have a class file that contains all the classes that are needed for a certain web application. Currently I'm at line 7269 and it contains numerous classes. I'm not particularly worried but I've started to notice that when working on this file Visual Studio responds slower. I'm thinking that this may be caused by the size of the file and Visual Studio's re-compile after every enter key press.

Has anyone got any recommendations for limits to lines per file of classes per file or perhaps guidelines as to how/why I should move classes into separate files?

I found this regarding Java but I'm specifically concerned with VB and Visual Studio 2005

Maximum lines of code permitted in a Java class?

Thanks

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

Edit
Report

2 Answers

2

1 class, 1 File, annakata is absolutely right.

In some cases really big classes you might consider using partial classes to split them in different files.

With only one really big file... that must be a nightmare to work in a team, how do you guys do it? I am guessing no source control and every change you need to make you must copy it to a deployment copy of the project.

That is a disaster just waiting to happen. Imagine if by any chance that one file got corrupted?

answered 2008-12-17T11:35:54.353
1

Visual Studio 2008 has a few performance issues if a ASP.NET page is a little bit complicated or large. Fortunately, there is an official hotfix for the problem. Installing the hotfix really helped me a lot as Visual Studio 2008 got much faster, so I recommend giving it a try:

https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826

answered 2008-12-17T12:08:19.670

Your Answer