设计模式:JDK和Spring中常见的设计模式

设计模式 总结
工厂模式 封装创建过程,只对结果负责 BeanFactory、Calender
单例模式 全局唯一 ApplicationContext、Calender
原型模式 多重影分身之术 ArrayList、PrototypeBean
代理模式 找人办事,增强职责 ProxyFactoryBean、JDK动态代理、Cglib动态代理
策略模式 用户选择,结果统一,解决if...else...问题 InstiationStrategy
委派模式 干活算你的(被委派类),结果算我的(委派类) DispatchServlet、BeanDefinitionParserDelegate
模板方法模式 封装流程标准,子类个性化定制 JdbcTemplate、HttpServlet
适配器模式 兼容转接头 AdvisorAdapter、HandlerAdapter
装饰器模式 包装,同宗同源 I/O流:InputStream、BufferedReader
观察者模式 任务完成时通知 ContextLoaderListener

猜你喜欢

转载自www.cnblogs.com/fcb-it/p/13168511.html