Files
nexus/wiki/concepts/DRY原则.md
2026-04-22 12:02:55 +08:00

29 lines
897 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: "DRY原则"
type: concept
tags: [software-engineering, coding-standards, best-practices, dry]
sources: [开发经验与项目规范整理文档]
last_updated: 2025-12-30
---
## Definition
**DRY 原则Don't Repeat Yourself** 是一种软件开发原则,核心思想是:系统中的每一片知识都必须有一个单一、明确、权威的表述。避免重复代码,提炼公共逻辑,提高复用价值。
## Core Principles
- 消除重复代码
- 提炼公共逻辑到可复用模块
- 保持代码的单一事实来源
- 通过抽象和模块化实现代码复用
## Related Concepts
- [[单一职责原则]] — DRY 的前提是模块有清晰的职责
- [[模块化编程]] — DRY 的实现手段
- [[Vibe Coding]] — AI 辅助开发中避免重复生成相似代码的指导原则
## Source Reference
来源:[[开发经验与项目规范整理文档]]