简体   繁体   English

.NET Web应用程序中的OOP性能

[英]OOP performance in .NET web applications

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 taking up too much memory/processing power when a large amount of users access the site? 现在,我已经在我的Web项目中创建了类等,现在想知道当大量用户访问该站点时,它们是否不只是占用过多的内存/处理能力?

I mean, is something like LINQ not too intensive for a web application? 我的意思是,对于Web应用程序来说,像LINQ这样的东西不是太密集吗?

The web app is coming along nicely but am worried about performance. Web应用程序进展顺利,但担心性能。

It sounds like you may be prematurely optimizing your code. 听起来您可能过早地优化了代码。 OOP/LINQ can give you a very good, clear design. OOP / LINQ可以为您提供非常好的,清晰的设计。 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. 毕竟,您现在所做的提高性能的操作可能在6个月内就无关紧要了。

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). 除了一般回答外,很难用其他任何方法回答一般问题,但是如果您具有现代硬件以及“合理的”性能要求,那么我将完全不用担心(Hexxagonal的回答很明确)。

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. 通常,大多数Web应用程序的性能瓶颈不是Web服务器的CPU或内存-通过添加其他服务器场来升级它既便宜又有效。 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. 我已经开发了许多.Net Web应用程序,并且有大量的访问者,而且我从来没有希望过在设计中减少面向对象的设计。

Usually there's nothing wrong with OOP. 通常,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一样,您可能想看看Dapper.Net或收听Scott Hanselman 各自的播客节目 LINQ has a few performance issues, and if performance is really an issue, you should know the alternatives. LINQ存在一些性能问题,如果性能确实是一个问题,则应该知道替代方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM