开发者

OOP performance in .NET web applications

开发者 https://www.devze.com 2023-03-25 06:02 出处:网络
Just a general question, Im a new developer but very used to working with objects. Now Ive been creating my classes etc in my web project and am now wondering if theyre not simply开发者_Python百科 tak

Just a general question, Im a new developer but very used to working with objects. Now Ive been creating my classes etc in my web project and am now wondering if theyre not simply开发者_Python百科 taking up too much memory/processing power when a large amount of users access the site?

I mean, is something like LINQ not too intensive for a web application?

The web app is coming along nicely but am worried about performance.


It sounds like you may be prematurely optimizing your code. OOP/LINQ can give you a very good, clear design. This is infinitely more important than performance at this point in your development (since you are a new developer). Worry about performance down the road. After all, what you do now to improve performance may be irrelevant in 6 months.


It's hard to answer general questions with anything other than general responses, but if you have modern hardware, and "reasonable" performance requirements, I wouldn't worry about this at all (Hexxagonal's answer is spot on).

In general, the performance bottleneck for most web applications is not the web server CPU or memory - and it's cheap and efficient to upgrade that by adding additional server farm. The database is far more likely to become your bottleneck.

My general advice is to design for maintainability first off, and only worry about performance once you know you have a problem; then measure and identify the bottleneck before you try to optimize.

I've worked on many .Net web apps, with very large numbers of visitors, and I've never once wished I'd reduced the object orientation in my design.


Usually there's nothing wrong with OOP. However, as you mention LINQ, you might want to have a look at Dapper.Net , or listen to the respective podcast episode by Scott Hanselman. LINQ has a few performance issues, and if performance is really an issue, you should know the alternatives.

0

精彩评论

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