GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - WeihanLi/DesignPatterns: DesignPatterns samples by CSharp《大话设计模式》 中设计模式总结/C#(.NET)代码

BranchesTags
Open more actions menu

Latest commit

 

History

144 Commits
144 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
BehaviorPattern
BehaviorPattern
 
 
CreatePattern
CreatePattern
 
 
StructurePattern
StructurePattern
 
 
uml
uml
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
DesignPatterns.slnx
DesignPatterns.slnx
 
 
Directory.Build.props
Directory.Build.props
 
 
Directory.Build.targets
Directory.Build.targets
 
 
LICENSE
LICENSE
 
 
Principles.md
Principles.md
 
 
README.md
README.md
 
 
azure-pipelines.yml
azure-pipelines.yml
 
 
大话设计模式.pdf
大话设计模式.pdf
 
 

Repository files navigation

DesignPatterns

Intro 简介

Design patterns from 《大话设计模式》 and some samples implemented by C#.

《大话设计模式》 中设计模式总结,示例代码是用 C# 写的,如果需要自己编译请安装 .NET SDK,下载 PDF 点这里

设计模式设计原则

  • 单一职责原则

    对于一个类而言,应该仅有一个引起它变化的原因

    如果一个类承担的职责过多,就等于把这些职责耦合再一起,一个职责的变化可能会削弱或者抑制这个类完全其他职责的能力。这种耦合会导致脆弱的设计,当发生变化时,设计会遭受到意想不到的破坏。

  • 开放-封闭原则

    开放-封闭原则是说软件实体(类、模块、函数等等)应该可以扩展,但是不可修改。

    对于扩展开放,对于更改封闭

  • 依赖倒转原则

    • 高层模块不应该依赖低层模式,两个都应该依赖抽象。
    • 抽象不应该依赖细节,细节应该依赖于抽象。基于接口编程。
  • 里氏代换原则

    子类型必须能够替换掉它们的父类型

  • 接口隔离原则

    使用多个隔离的接口,比使用单个接口好,建立最小的接口

    一个接口只负责一个功能

  • 迪米特法则

    如果两个类不必彼此通信,那么这两个类就不应当发生直接的相互作用。如果其中一个类需要调用另一个类的某一个方法,可以通过第三者转发这个调用。

    类的结构设计上,每一个类都应当尽量降低成员的访问权限

    类之间的耦合越弱,越有利于复用,一个处在弱耦合的类别修改,不会对有关系的类造成波及

Overview 概览

image

设计模式大体上可分为三类:

  • 创建型模式(Create)

    1. 简单工厂(SimpleFactory)
    2. 抽象工厂(AbstractFactory)
    3. 工厂方法(FactoryMethod)
    4. 建造者模式(Builder)
    5. 原型模式(Prototype)
    6. 单例模式(Singleton)
  • 结构型模式(Structure)

    1. 适配器模式(Adapter)
    2. 桥接模式(Bridge)
    3. 组合模式(Composite)
    4. 装饰(者/器)模式(Decorator)
    5. 外观/门面模式(Facade)
    6. 享元模式(Flyweight)
    7. 代理模式(Proxy)
  • 行为型模式(Behavior)

    1. 观察者模式(Observer)
    2. 模板方法(TemplateMethod)
    3. 命令模式(Command)
    4. 状态模式(State)
    5. 职责链模式(Chain of Responsibility)
    6. 解释器模式(Interpreter)
    7. 中介者模式(Mediator)
    8. 访问者模式(Visitor)
    9. 备忘录模式(Memento)
    10. 迭代器模式(Iterator)
    11. 策略模式(Strategy)

UML 类图:本项目包含了所有设计模式的 UML 类图,位于 uml 文件夹中,使用 PlantUML 格式,可在线渲染或本地查看。

About

DesignPatterns samples by CSharp《大话设计模式》 中设计模式总结/C#(.NET)代码

Topics

csharpdesign-patterndesign-patternsdesignpatternsdotnetdotnetcoreooppatterns

Resources

Readme
MIT license
Activity

Stars

171 stars

Watchers

4 watching

Forks

57 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.