> For the complete documentation index, see [llms.txt](https://php7.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://php7.shujuwajue.com/php-biao-zhun-gui-fan-ji-kai-fa-ji-qiao/mian-xiang-dui-xiang-bian-cheng-de-ji-ben-yuan-ze.md).

# 面向对象编程的基本原则

1. **单一职责原则**：一个类，只需要做好一件事情．
2. **开放封闭原则**：一个类，应该是对扩展是开放的，但是对修改是封闭的；不应该使用修改增加功能，而是通过扩展来增加功能.
3. **依赖倒置原则**：一个类，不应该强依赖另外一个类．每个类对于另外一个类都是可替换的．
   1. 比如有A和B两个类，当A类依赖B类时，A类不能在其中直接调用B类，而是应该使用依赖注入的方式，通过注入将B类对象注入给A类，这样B类对于A类来说就是可以替换的.当新类C类实现了与B类实现了一致的接口类，这样就可以在B类和C类之间切换．
4. **配置化原则**：尽可能地使用配置，而不是硬编码．
5. **面向接口编程原则**：只需要关心接口，不需要关心实现．


---

# 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://php7.shujuwajue.com/php-biao-zhun-gui-fan-ji-kai-fa-ji-qiao/mian-xiang-dui-xiang-bian-cheng-de-ji-ben-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.
