Files
Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
PHP设计模式
面向对象的目标
面向对象设计的基本原则
- 单一职责:一个类只做一件事
- 开闭原则:对扩展开放对修改关闭
- 里氏替换:子类必须能替换所有父类的使用
- 依赖倒置:设计依赖于抽象而不是实现
- 最少知识:对象应当尽可能少的去了解其他对象
- 接口隔离:接口倾向于小而多
- 组合优先:优先使用类的组合而不是继承
抽象类和接口的使用
- 当类中有共同的行为或属性时,可以考虑使用 abstract calss
- 当类别中有共同的操作界面,但是在实现上有所差别,可以考虑使用 interface
About
PHP中常用的设计模式的一些小demo
Topics
Resources
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.