开发者

C# file size limit

I have a website built with ASP.NET (.NET 2.0). I have a lot of classes in my business logic, and I keep all of them in one file (BL.cs).

I now got to a stage where I have 11,000 lines of code in this file. Is this a problem - should I separa开发者_StackOverflow社区te it into several files, each class in a different file? Is there a limit that the cs file shouldn't exceed?


I stick to the following rule: 1 file per class (unless for nested classes of course). 11,000 lines of code in a single file looks monstrous.


To be honest I don't know if there is a size limit, but 11.000 lines of code is a lot to handle in a single file.

You will find that VS runs a lot smoother if you split the code into multiple files and it will make it easier for you and your fellow developers to focus on a specific set of classes for any given task.

Programming is all about building complex systems from simple parts. Storing all your parts in a single, giant file goes against that idea.


You should keep each class in separate file for better readability and managability.


I doubt there's a limit on the file size, I've seen EF files at 30k+ lines, however, you should be separating everything into individual files anyway for just plain usability and readability reasons.


This is very much a problem from a maintability point of view.

You will almost never need hand written code to be more than a few hundred lines per class and you should always aim to use one class per file ( and name files with the same name as your class ). This is general good form for managing a project, especially a large one.

If this is one huge auto-generated class you might consider splitting it into multiple files using the partial keyword in each.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜