> For the complete documentation index, see [llms.txt](https://mm.ricky.moe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mm.ricky.moe/other/ji-suan-ji-li-lun/solid-yuan-ze.md).

# solid原则

S.O.L.I.D是面向对象设计和编程(OOD\&OOP)中几个重要编码原则(Programming Priciple)的首字母缩写。

| **SRP** | [The Single Responsibility Principle](http://www.objectmentor.com/resources/articles/srp.pdf) | 单一责任原则 |
| ------- | --------------------------------------------------------------------------------------------- | ------ |
| **OCP** | [The Open Closed Principle](http://www.objectmentor.com/resources/articles/ocp.pdf)           | 开放封闭原则 |
| **LSP** | [The Liskov Substitution Principle](http://www.objectmentor.com/resources/articles/lsp.pdf)   | 里氏替换原则 |
| **ISP** | [The Interface Segregation Principle](http://www.objectmentor.com/resources/articles/isp.pdf) | 接口分离原则 |
| **DIP** | [The Dependency Inversion Principle](http://www.objectmentor.com/resources/articles/dip.pdf)  | 依赖倒置原则 |

总结：

1. 一个对象只承担一种责任，所有服务接口只通过它来执行这种任务。
2. 程序实体，比如类和对象，向扩展行为开放，向修改行为关闭。
3. 子类应该可以用来替代它所继承的类。
4. 一个类对另一个类的依赖应该限制在最小化的接口上。
5. 依赖抽象层(接口)，而不是具体类。

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mm.ricky.moe/other/ji-suan-ji-li-lun/solid-yuan-ze.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
