开发者

Static methods vs singletons [duplicate]

开发者 https://www.devze.com 2023-03-13 20:22 出处:网络
This question already has answers here: Closed 11 years ag开发者_开发百科o. Possible Duplicate: Why choose a static class over a singleton implementation?
This question already has answers here: Closed 11 years ag开发者_开发百科o.

Possible Duplicate:

Why choose a static class over a singleton implementation?

Static methods vs singletons.

Could it be determined choice here?

What are conditions in which one of these approaches is definetely more suitable then other?


Static methods follow the "low coupling and high coherence"-rule more than singletons do. (As long as their implementations don't rely on static member variables.)


If the static methods solve the same problem as the singleton, then why complicate and write a singleton?

Otherwise, why choose something that solves the wrong problem?

0

精彩评论

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

关注公众号