Files
nexus/wiki/concepts/单一职责.md
2026-04-14 16:02:50 +08:00

27 lines
646 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "单一职责"
type: concept
tags: [编码, 原则]
sources: [dev-experience-standards]
last_updated: 2026-04-14
---
## Definition
每个文件、类、函数只负责一件事的软件设计原则。
## 实践
- 提炼公共逻辑
- 避免重复代码DRY
- 模块化、函数化,提高复用价值
## 输入输出划分
| 概念 | 说明 |
|------|------|
| 消费端 | 接收外部数据或依赖输入 |
| 生产端 | 生成数据、输出结果 |
| 状态 | 存储当前系统信息的变量 |
| 变换 | 处理状态、改变数据的逻辑 |
## Connections
- [[开发经验与规范]] ← 原则 ← [[单一职责]]