软件架构设计几大原则
所属分类 architecture
浏览量 1429
SOLID
单一职责原则(Single Responsibility Principle - SRP)
There should never be more than one reason for a class to change.
开放封闭原则(Open Closed Principle - OCP)
Software entities like classes, modules and functions should be open for extension but closed for modifications.
对扩展开放,对修改封闭
里氏替换原则(Liskov Substitution Principle - LSP)
Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
父类能够替换子类,但子类不一定能替换父类。
最少知识原则(Least Knowledge Principle - LKP)
Only talk to you immediate friends.
只与最直接的朋友交流
尽量减少对象之间的交互,减少类之间的耦合。低耦合,高内聚。
接口隔离原则(Interface Segregation Principle - ISP)
The dependency of one class to another one should depend on the smallest possible interface.
不要对外暴露没有实际意义的接口。
依赖倒置原则(Dependence Inversion Principle - DIP)
High level modules should not depends upon low level modules.
Both should depend upon abstractions. Abstractions should not depend upon details.
Details should depend upon abstractions.
其他原则
组合/聚合复用原则(Composition/Aggregation Reuse Principle - CARP)
扩展类功能时,优先考虑使用组合,而不是继承。
无环依赖原则(Acyclic Dependencies Principle - ADP)
共同封装原则(Common Closure Principle - CCP)
共同重用原则(Common Reuse Principle - CRP)
好莱坞原则(Hollywood Principle - HP)
好莱坞明星的经纪人一般都很忙,他们不想被打扰,往往会说:Don't call me, I'll call you.
控制反转 依赖注入
不要重复你自己(Don't repeat yourself - DRY)
保持它简单与傻瓜(Keep it simple and stupid - KISS)
高内聚与低耦合(High Cohesion and Low Coupling - HCLC)
惯例优于配置(Convention over Configuration - COC)
命令查询分离(Command Query Separation - CQS)
关注点分离(Separation of Concerns - SOC)
契约式设计(Design by Contract - DBC)
你不需要它(You aren't gonna need it - YAGNI)
避免过度设计
上一篇
下一篇
springIOC容器相关注解
springboot简单例子
利用shell命令分析java线程堆栈
网页上显示html和xml代码的几种方法
linux手工释放cache
如何让pre元素里的内容自动换行