永不磨灭的设计模式(有这一篇真够了,拒绝标题党)

[版权申明] 非商业目的注明出处可自由转载
博文地址:https://blog.csdn.net/ShuSheng0007/article/details/115980889
出自:shusheng007

文章目录

  • 概述
  • 定义
  • 分类
    • 创建型(creational)
    • 结构型(structural)
    • 行为型(behavioral)
  • 总结

概述

在IT这个行业,技术日新月异。有可能你今年刚弄懂一个编程框架,明年它就不流行了,无怪乎有些无节操的IT从业人员去GitBub上用汉语提Issue:“求你别更新了,实在学不动了”。对于这种行为我只能说,太jb不要脸了…

然而即使在易变的IT世界也有很多几乎不变的知识,他们晦涩而重要,默默的将程序员划分为卓越与平庸两类,例如算法,例如我们今天要说的设计模式,等等。你要成为卓越那一类吗,let’s go

定义

英文:

In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.

汉语:

在软件工程领域,设计模式是一套通用的可复用的解决方案,用来解决在软件设计过程中产生的通用问题。它不是一个可以直接转换成源代码的设计,只是一套在软件系统设计过程中程序员应该遵循的最佳实践准则。

从定义可以看出,设计模式是一套语言无关的最佳设计实践准则,我们这里主要介绍GOF的面向对象的23种设计模式。

分类

设计模式安装其要解决的问题一般被分为3类:

创建型(creational)

顾名思义,主要解决如何灵活创建对象或者类的问题,共5个

  1. 抽象工厂模式(Abstract Factory)

秒懂设计模式之抽象工厂模式(Abstract Factory Pattern)

  1. 工厂方法模式(Factory Method)

秒懂设计模式之工厂方法模式(Factory Method Pattern)

  1. 构建者模式(Builder)

秒懂设计模式之建造者模式(Builder pattern)

  1. 单例模式(Singleton)

敬请期待

  1. 原型模式(Prototype)

秒懂设计模式之原型模式(Prototype Pattern

另外还有一个简单工厂模式,不在GOF 23种设计模式之中。
秒懂设计模式之简单工厂模式(Simple Factory Pattern)

结构型(structural)

结构型设计模式主要用于将类或对象进行组合从而构建灵活而高效的结构,共7个。

  1. 适配器模式(Adapter)

秒懂设计模式之适配器模式(Adapter Pattern)

  1. 桥接模式(Bridge)

秒懂设计模式之桥接模式(Bridge Pattern)

  1. 组合模式(Composite)

秒懂设计模式之组合模式(Composite Pattern)

  1. 装饰者模式(Decorator)

秒懂设计模式之装饰者模式(Decorator Pattern)

  1. 外观模式(Facade)

秒懂设计模式之外观模式(Facade Pattern)

  1. 享元模式(Flyweight)

秒懂设计模式之享元模式(Flyweight Pattern)

  1. 代理模式(Proxy)

秒懂Java代理与动态代理模式(Proxy Pattern)

行为型(behavioral)

行为型设计模式主要解决类或者对象直接互相通信的问题,共11个

  1. 责任链模式(Chain of responsibility)

秒懂设计模式之责任链模式(Chain of responsibility)

  1. 命令模式(Command)

秒懂设计模式之命令模式(Command Pattern),王二狗背着媳妇又搞事了

  1. 解释器模式(Interpreter)
  2. 迭代器模式(Iterator)
  3. 中介者模式(Mediator)
  4. 备忘录模式(Memento)
  5. 观察者模式(Observer)
  6. 策略模式(Strategy)

秒懂设计模式之策略模式(Strategy Pattern)

  1. 状态模式(State)

秒懂设计模式之状态模式(State Pattern)

  1. 模板方法模式(Template method)

秒懂设计模式之模板方法模式(Template Method Pattern)

  1. 访问者模式(Visitor)

总结

本篇为设计模式汇总篇,我会不断的完善补全其中没有实例的设计模式,你可以先点赞收藏起来,那样就再也不怕找不到走向卓越的路了。

你可能感兴趣的:(设计模式,设计模式,java)