Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设计原则 #56

Open
MengZhaoFly opened this issue Jan 4, 2020 · 0 comments
Open

设计原则 #56

MengZhaoFly opened this issue Jan 4, 2020 · 0 comments

Comments

@MengZhaoFly
Copy link
Owner

MengZhaoFly commented Jan 4, 2020

SOLID

  • 单一功能:一个模块一个能力
  • 开闭原则:对扩展开放,对修改封闭的,
    • 开放:函数,模块可以有扩展性
    • 封闭:尽量少开放可以修改本模块内部变量的方法
  • 里氏替换
    • 面向对象里面的继承
  • 接口隔离
    • 使用多个专门的接口
  • 依赖注入
    • 相当于原来有一些模块它们互相依赖,为了解决他们的依赖,再次抽象出一个 “容器” 来管理几个模块,由 ”容器“ 将依赖注入到模块中。比如 React 里面的 connect

控制反转

一种面向对象的设计原则,
Inversion of Control:控制反转,减低计算机代码之间耦合度。
其中最常见的方式:

  • 依赖注入, 简称 DI (Denpendency Injection)
  • 依赖查找,(Denpendency Lookup)

面向切面编程

常见的例子:

  • 对原生方法的一些劫持
  • 一些生命周期
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant