GOF23种设计模式类型、描述和类图(上)

单例模式

类型:创造

描述:Java 中最简单的设计模式之一。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。这种模式涉及到一个单一的类,该类负责创建自己的对象,同时确保只有单个对象被创建。这个类提供了一种访问其唯一的对象的方式,可以直接访问,不需要实例化该类的对象。

英文描述:

Ensure a class has only one instance,and provide a global point of access to it.

类图

工厂方法模式

类型:创造

描述: 定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法是一个类的实例化延迟到子类。

英文描述:

Define an interface for creating an object,but let subclasses decide which class to instantiate.Factory Method lets a class defer instantiation to subclasses.

类图

抽象工厂模式

类型:创造

描述:  为创建一组相关或者相互依赖的对象提供一个接口,而且无需指定他们的具体类。

英文描述:

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

类图

建造者模式

类型:创造

描述:  将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。

英文描述:

Separate the construction of a complex object from its representation so that the same construction process can create different

类图

原型模式

类型:创造

描述: 用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。

英文描述:

Specify the kind of objects to create using a prototypical instance,and create new objects by copying this prototype.

类图

迭代器模式

类型:创造

描述:  提供一种方法访问一个容器对象中各个元素,而不暴露该对象的内部细节。

英文描述:

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

类图

命令模式

类型:行为

描述:  一种数据驱动的设计模式,它属于行为型模式。请求以命令的形式包裹在对象中,并传给调用对象。调用对象寻找可以处理该命令的合适的对象,并把该命令传给相应的对象,该对象执行命令。

英文描述:

Encapsulate a request as an object,thereby letting you parameterize clients with different requests,queue or log requests,and support undoable operations.

类图

解释器模式

类型:行为

描述:  提供了评估语言的语法或表达式的方式,它属于行为型模式。这种模式实现了一个表达式接口,该接口解释一个特定的上下文。这种模式被用在 SQL 解析、符号处理引擎等。

英文描述:

Given a language,define a representation for its grammer along with an interpreter that uses the representation to interpret that uses the representation to interpret sentences in the language.

类图

来都来了 点个赞再走吧~~~

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

田哥coder

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值