经常使用的设计模式有哪些,做用是什么
设计模式一共23种,经常使用的设计模式有:html
单例模式的懒汉和饿汉模式你了解吗
懒汉模式:太懒了,第一次用的时候才去实例化,适合使用量较小的状况。算法
public class Singleton { private Singleton() { } private static Singleton singleton = null; public static Singleton getInstance() { if (singleton == null) { singleton = new Singleton(); } return singleton; } }
饿汉模式:很勤快,类定义的时候就实例化了。线程安全的,适合访问量比较大的状况。设计模式
public class Singleton { private Singleton(){ } private static final Singleton singleton = new Singleton(); public static Singleton getInstance(){ return singleton; } }
Spring框架用到了哪些设计模式安全
你怎么选择合适的设计模式
考虑设计模式怎么解决问题,找出与使用者问题相关的模式,研究模式如何相互关联,考虑设计中那些是可变的,尽量实现强内聚,松耦合。框架
http://www.javashuo.com/article/p-gvbnwude-ka.html
http://c.biancheng.net/design_pattern/
http://www.javashuo.com/article/p-vnqbejmv-hc.htmlspa