Files
nexus/wiki/concepts/单一职责原则.md

29 lines
942 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: [software-engineering, solid, coding-standards, design-principle]
sources: [开发经验与项目规范整理文档]
last_updated: 2025-12-30
---
## Definition
**单一职责原则Single Responsibility Principle, SRP** 是 SOLID 面向对象设计原则之一,核心思想是:每个模块、类、函数应该只负责一件事,只有一个引起它变化的原因。
## Core Principles
- 每个文件只负责一个功能
- 每个类只负责一个领域
- 每个函数只处理一个任务
- 当需求变化时,只有某一个原因会导致该模块修改
## Related Concepts
- [[DRY原则]] — 避免重复代码,与单一职责互补
- [[模块化编程]] — 单一职责的具体实现方式
- [[输入-处理-输出模型]] — 系统行为的划分框架
## Source Reference
来源:[[开发经验与项目规范整理文档]]