
很久没写了,工作时间一长,琐细、重复的事情做多了,确实会逐渐消磨了热情,尤其是大环境喧嚣又浮躁,有时候真就感叹人生苦短,譬如朝露,倏忽间时间就过去了。
Abstraction
计算机科学的基本原则之一。
SOLID
- S ingle Responsibility Principle,SRP 单一职责原则
- O pen-Closed Principle,OCP 开放封闭原则
- L iskov Substitution Principle,LSP 里氏替换原则(行为一致)
- I nterface Segregation Principle,ISP 接口隔离原则
- D ependency Inversion Principle,DIP 依赖倒置原则
Origin:<Design Principles and Design Patterns > – Robert C. Martin
DRY
Don’t Repeat Yourself.
Origin:《The Pragmatic Programmer 》- Andy Hunt & Dave Thomas
KISS
Keep It Simple, Stupid.
Origin: U.S. Navy
YAGNI
You Aren’t Gonna Need It.
Origin:《Extreme Programming Installed 》- Jeffries, Ronald E.
SoC
Separation of Concern.
Origin:<On the role of scientific thought> – Edsger W. Dijkstra
LoD / LKP
Law of Demeter ( Least Knowledge Principle ).
Origin: <Assuring good style for object-oriented programs> – Lieberherr, K.J.
GRASP
General Responsibility Assignment Software Patterns.
- Creator,谁来创建对象?尽量由包含、记录、最接近、有其初始化所需信息的地方来创建;
- Information Expert,把职责分配给具有完成该职责所需信息的类;
- Low Coupling
- Controller,UI 层之上的第一个类,代表整个“系统”、“根对象”、运行软件的设备或主要子系统,或者代表发生系统行为的用例场景;
- High Cohesion
- Indirection,引入中间层,避免多个事物之间直接耦合,总线、MQ 也是该类思想的体现;
- Protected Variations,识别变化或不稳定处,围绕其创建稳定抽象接口,避免对其他元素产生不良影响;
- Polymorphism,当相关选择或行为随类型有所不同时,使用多态操作为变化的行为类型分配职责;
- Pure Fabrication,当职责无法放入任何领域对象,就创建一些高内聚的纯属虚构的类来行使这些职责。
Origin:《Applying UML and Patterns 》- Craig Larman 2004
1 条评论
Chris · 2025年3月11日 下午5:58
great post !