设计模式
文章平均质量分 92
muyeqianli
这个作者很懒,什么都没留下…
展开
-
设计模式六大原则
1.单一职责原则(Single ResponsibilityPrinciple,SRP):定义:There should never be more than one reason for a class tochange。不要存在多于一个导致类变更的原因。通俗的说,即一个类只负责一项职责。核心思想:类的职责要单一,不能将太多的职责放在一个类中。(高内聚、低耦合)问题由来:类T负责原创 2016-06-29 14:39:22 · 342 阅读 · 0 评论 -
单例模式
1.单例模式的定义:Ensure a class has only one instance, and provide a global point of access to it。(保证一个类仅有一个实例,并提供一个访问它的全局访问点。)2.单例模式结构图:这里写图片描述 3.单例模式写法:(1)饿汉模式:public class Singleton {原创 2016-10-31 21:32:37 · 277 阅读 · 0 评论