开发者

Does the ASP.NET C# page size matter

I am working on an asp.net web site that is based upon a single gateway page that typically handles all requests and responses. There are a number of classes that get called by the gateway page depending on what's going on, but there is a lot of code within the main gateway page, split into lots of methods. I understand that the JIT compiler will only load and JIT methods as they become required, and therefore the smaller my methods the better. However, my question is this: does it matter if I have thousands of lines and hundreds of methods within the same aspx.cs file? Should I try to break down the functionality into smaller source files, classes and namespaces? Or in reality will this not make much difference because the .net runtime will only jit and load each method as it becomes necessary? I appreciate people may have coding style contributions here, but I'm realy i开发者_高级运维nterested to know exactly what .NET is doing technically so I can make my decision based upon pure performance criteria. Thanks very much. If I do 'refactor', what sort of performance difference might I expect to see?


I would immediately fire anyone who produced a single class with 25,000 lines of code. It's a sign of ignorance of modern software development practices.


Profile, profile, profile!

You are worrying about a perceived performance problem that you might not have.

I would be much more worried about the maintainability of your code.


There is no performance issue just because it is in a single file. The issue you have is primarily around maintenance, lack of focus on coding best practices and testability.


If it is a single class, create multiple file with 'partial class'. If you have more than one class in your aspx.cs file, put each class in its own file. It will not achieve any performance gain, but will make your code much-much maintainble


I don't think that you are going to get anything out of that other than creating a more maintainable solution. If you are having performance problems, instead of trying to hack around with the JIT why not upgrade your hardware.

Rather concentrate on making good quality, easily maintainable good and let the JIT compiler do what it does best.


The performance difference will be minor but a perfect performance is (nearly) irrelevant in most cases. What is a millisecond or less saved compared to 40 hours developer time required to make a small change. The Program has to be executed a lot to be worth that time.


There are a few things to note

  1. Refactoring your code or dividing your code in multiple files wont have any performance benefit as all classes are finally compiled. But it will help you to manage your code. If you can manage them then no problems.

  2. When a request is sent to the server, the final response sent back is html and it does not matter how that html was generated.

In my view refactoring or separating your code into multiple files won't boost your application's performance but may boost your coding performance.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜