本文介绍了在项目中有很多单身人士课程是否有好的编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么最好的方法?
- 可以将其创建为静态对象。
- 可以创建为单例
- 可以创建为全局。
实现这一点的最佳设计模式是什么?
$ b $我正在考虑将所有课程都创建为单身人士,但这将创造出许多单身人士。有很多单身吗?
使用单身人士的利弊是什么?
解决方案
看看Steve Yegge关于这个的博客文章 -
I have a few classes in a project that should be created only once.
What is the best way to do that?,
- They can be created as static object.
- Can be created as singleton
- Can be created as global.
What is the best design pattern to implement this?
I am thinking of creating all classes as singleton, but that would create lot of singletons. Is it good programming practice to have lot of singletons?
What are the pros and cons for using singletons?
解决方案
Take a look at Steve Yegge's blog post about this - Singleton Considered Stupid
这篇关于在项目中有很多单身人士课程是否有好的编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!