Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 separate it into several files, each class in a different file? Is there a limit that the cs file shouldn't exceed?

like image 632
Lea Cohen Avatar asked May 12 '11 06:05

Lea Cohen


3 Answers

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.

like image 142
Darin Dimitrov Avatar answered Sep 27 '22 23:09

Darin Dimitrov


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

like image 30
FIre Panda Avatar answered Sep 27 '22 23:09

FIre Panda


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.

like image 26
Brian Rasmussen Avatar answered Sep 27 '22 21:09

Brian Rasmussen