静态方法是否有利于可伸缩性? [英] Are static methods good for scalability?

查看:165
本文介绍了静态方法是否有利于可伸缩性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

静态方法和类是否有利于可伸缩性?我认为静态类/方法可以提高应用程序的可伸缩性,而实例方法不会扩展太多。那么在可能的情况下编写静态方法是不是很好的编程习惯呢?

Does static methods and class are good for scalability ? I think so static class/method improves scalability of application and instance methods doesn't scales much. So is it good programming practice to write static method where ever it is possible ?

推荐答案

这取决于为什么该方法是静态的。如果它是静态的,因为它确实不需要上下文,那么与相似的复杂性相比,它可能会非常好地扩展,因为它需要上下文。

It depends on WHY the method is static. If it's static because it truly does not need context, then it will probably scale very well compared to something of similar complexity that is not static because it requires context.

但是,如果它是静态的仅仅是因为你不能保留所需的上下文并且仍然必须传递它,或者由于某些人工目标有更多的静态方法,那么我会怀疑它实际上将比非静态的可比方法缩放LESS。

However, if it is static merely because you cannot retain the needed context and must still pass it in, or because of some artificial goal of having more static methods, then I would suspect that it will actually scale LESS than the comparable method as non-static.

事实上,我认为ASP Classic证明了这一点。

In fact I think that ASP Classic proved this point.

这篇关于静态方法是否有利于可伸缩性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆