wve

导航

文章分类 -  设计模式

单例模式
摘要:Singleton PatternEnsure a class has only one instance,and provide a global point of access to it. 阅读全文

posted @ 2012-08-28 11:44 wve 阅读(80) 评论(0) 推荐(0)

单一职责
摘要:Single Responsibility Principle SRP 阅读全文

posted @ 2012-08-04 11:11 wve 阅读(127) 评论(0) 推荐(0)

开闭原则
摘要:software entities like classes, modules and functions should be open for extension but closed for modifications. 软件实体应该对外开放,对修改关闭,其含义是说一个软件实体应该通过扩展来实现变化,而不是通过修改已有的代码来实现变化。 如何应用: 抽象约束 第一通过接口或抽象类约束扩展,对扩展进行边界界定,不允许出现在接口或抽象类中不存在的public方法;第二参数类型、引用对象尽量使用接口或抽象类,而不是实现类;第三抽象层尽量保持稳定,一旦确定即不允许修改。 元数据控... 阅读全文

posted @ 2012-08-02 12:21 wve 阅读(137) 评论(0) 推荐(0)

接口隔离原则
摘要:接口分为两种:实例接口类接口接口隔离原则是对接口进行规范约束,其包含以下四层含义: 接口尽量小,根据接口隔离原则拆分接口时,首先必须满足单一职责。 接口要高内聚 定制服务接口设计是有限度的 阅读全文

posted @ 2012-08-01 14:04 wve 阅读(125) 评论(0) 推荐(0)

迪米特法则
摘要:Law of Demeter , LoDLeast Knowledge Principle , LKP 一个对象应该对其他对象有最少的了解。只和朋友交流 Only talk to your immedate friends2. 朋友间也是有距离的3.是自己的就是自己的4.谨慎使用Serializable是 阅读全文

posted @ 2012-07-31 15:24 wve 阅读(126) 评论(0) 推荐(0)

里氏替换原则
摘要:Liskov Subsitution Principle, LSP : If for object o1 of type S there is an abject o2 of type T such that for all programs P defined in terms of T,the behavior of P is unchanged when o1 is subsituted for o2 then S is a subtype of T. Functions that use pointers or reference to base classes must be a.. 阅读全文

posted @ 2012-07-30 10:22 wve 阅读(119) 评论(0) 推荐(0)

依赖倒置原则
摘要:Dependence Inversion Principle , DIP High level modules should not depend upon low level modules.Both should depend upon abstractions.Abstractions should not depend upon details. Details should depend upon abstractions. 三层含义: 高层模块不应该依赖低层模块,两者都应该依赖其抽象。 抽象不应该依赖其细节。 细节应该依赖抽象。依赖倒置原则在java语言中的表现就是:模块... 阅读全文

posted @ 2012-07-26 10:33 wve 阅读(141) 评论(0) 推荐(0)