![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
文章平均质量分 82
freesonfish
乐观,工作积极认真,勤奋吃苦,富有团队精神。
展开
-
学习设计模式之禅——6大设计原则
一年前就拥有秦小波写的《设计模式之禅》,由于时间和项目经验原因,一直都没有仔细阅读,最近抽时间学习。 里面首先介绍的是程序设计的6大原则。 1、单一职责原则(Single Responsibility Principle 简称是SRP),接口、类、方法尽量做到单一。 2、里氏替换原则(If for each object o1 of type S there is an object原创 2013-09-21 23:28:56 · 910 阅读 · 2 评论 -
学习设计模式之禅——模板方法模式
模板方法模式(Template Method Pattern)定义:Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm withou原创 2013-09-27 21:24:13 · 707 阅读 · 0 评论 -
学习设计模式之禅——抽象工厂方法模式
抽象工厂模式(Abstract Factory Pattern)是一种比较常用的模式,其定义如下: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.(创建一组相关或相互依赖的对象提供一个接口,而且无需制定他们的具原创 2013-09-26 20:44:03 · 825 阅读 · 0 评论 -
学习设计模式之禅——中介者模式
中介者模式的定义为:Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their inte原创 2013-10-30 23:20:36 · 930 阅读 · 0 评论 -
学习设计模式之禅——原型模式
原型模式(Prototype Pattern)的简单程度仅此于单例模式和迭代器模式。正是由于简单,使用的场景非常多,其定义如下: Specify the kind of object to create using a prototypical instance, and create new objects by copying this prototype。(用原型实例指定创建对象的种类,并原创 2013-10-28 15:38:43 · 771 阅读 · 0 评论 -
学习设计模式之禅——工厂方法模式
工厂方法模式使用的频率非常高,在我们日常的开发中总能遇见到它的身影。其定义为:Define an interface for creating an object, but let subclass decide which class to instantiate.Factory Method lets a class defer instantiation to subclasses.(定义一原创 2013-09-25 21:33:55 · 974 阅读 · 0 评论 -
学习设计模式之禅——单例模式
单例模式:(Singleton Pattern)是一个比较简单的模式,其定义如下: Ensure a class has only one instance, and provide a global point of access to it.(确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例) 单例模式通用代码: public class Singleton { p原创 2013-09-23 22:27:42 · 817 阅读 · 0 评论 -
学习设计模式之禅——建造者模式
建造者模式(Builder Pattern)也叫生成器模式,起定义:Seperate the construction of a complex object from its representation so that the same construction process can create different representations.(将一个复杂的对象的构建与它的表示分离,使原创 2013-10-10 20:50:43 · 935 阅读 · 0 评论 -
学习设计模式之禅——代理模式
先看一个例子,是有关于打游戏杀怪兽的。 //先定义一个游戏者接口 public interface IGamePlayer { //登陆游戏 public void login(String user, String password); //杀怪,网络游戏的主要角色 public void killBoss(); //升级 public void upgrade(); } /原创 2013-10-21 20:21:19 · 1968 阅读 · 0 评论 -
学习设计模式之禅——命令模式
命令模式是一个高内聚的模式,其定义为:Encapsulate a request as an object,thereby letting you parameterize clients with different requests,queue or long queues,and support undoable operation(将一个请求封装成一个对象,从而让你使用不同的请求把客户端参原创 2013-11-10 15:27:04 · 1151 阅读 · 0 评论