microwind/ai-skills/ddd-vs-mvc
Claude Code and agent skill by microwind/ai-skills
- community
Checking that the SKILL.md file is still in the repository.
对比 MVC 模式与 DDD 方法论的差异,分析 MVC 在复杂业务下的局限性,帮助团队判断何时应采用 DDD。
Install
npx vskill@latest install microwind/ai-skills/ddd-vs-mvcSKILL.md
DDD 与 MVC 对比
概述
MVC(Model - View - Controller)是最广泛使用的应用分层模式。DDD(Domain-Driven Design)则是一种面向复杂业务的软件工程方法论。两者不是同一层面的概念,但在工程实践中经常被并列讨论,因为一个项目往往要在它们之间做选择。
一句话区别:
- MVC:软件层面的架构模式,关注"代码怎么分层"
- DDD:业务面向的方法论,关注"业务如何建模、团队如何拆分、系统如何演进"
MVC 模式的结构
典型代码组织:
MVC 在复杂业务下的三大问题
1. MVC 不含业务语言
业务专家看不懂"updateStatus(2)"是什么意思。DDD 要求所有代码使用[通用语言](../ubiquitous-language/),让代码直接表达业务。
2. 数据和行为被天然割裂
MVC 默认数据放在 Model(数据库实体)里,行为放在 Service 里,这会导致:
- Service 越来越厚,变成"万能神类"
- Model 变成纯 DTO,完全没有业务知识
- 业务规则散落在各个 Service 方法中,难以复用和维护
DDD 则倡导 **充血模型**:把业务规则放回领域对象,order.pay()、order.ship() 自己保护自己的状态。
3. 缺乏顶层边界划分
DDD 通过[领域](../domain-partitioning/)、[子域](../domain-types/)、[限界上下文](../bounded-context/) 解决顶层边界问题,为微服务拆分、团队分工提供系统方法。
MVC 与 DDD 的关系
换句话说,MVC 可以看作 DDD 分层架构的极简版。
对比表
| 维度 | MVC | DDD | |
|---|---|---|---|
| 定位 | 分层模式 | 方法论 / 架构思想 | |
| 驱动对象 | 技术分层 | 业务领域 | |
| 核心概念 | Model / View / Controller | 领域、子域、限界上下文、聚合、实体、值对象… | |
| 业务规则归属 | 多散落在 Service | 集中在领域层(领域模型 + 领域服务) | |
| 数据模型 | 通常 = 数据库模型 | 领域模型 ≠ 数据模型,仓储做转换 | |
| 统一语言 | 无要求 | 核心要求 | |
| 边界划分 | 无规范 | 限界上下文明确边界 | |
| 团队协作 | 靠规范 | 限界上下文即团队划分单元 | |
| 学习成本 | 低 | 较高 | |
| 适用场景 | 业务简单、项目小 | 业务复杂、长期演进、多团队 |
选型决策表
演进路径
实际项目中,从 MVC 向 DDD 演进是常见做法,而非一步到位:
与其他 DDD 概念的关系
| 概念 | 关系 | |
|---|---|---|
| 领域模型 | 充血模型是 DDD 对贫血 MVC Model 的回应 | |
| 限界上下文 | 解决 MVC 无法回答的"系统如何拆分"问题 | |
| DDD 分层架构 | DDD 下的工程落地分层,可视为 MVC 的演进 | |
| 通用语言 | DDD 对 MVC 缺乏业务语言的修正 |
总结
核心:MVC 解决代码分层问题,DDD 解决业务建模和系统边界问题。
实践原则:
- 简单业务用 MVC,不要为了 DDD 而 DDD
- 复杂业务用 DDD,但核心在于领域建模,而非模板化分层
- 深刻理解业务 > 任何设计方法论——DDD 是工具,不是目标
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdomain-driven-design/ddd-vs-mvc/SKILL.md
Popularity
- Repository stars
- 68
- Repository forks
- 17
- 7-day trend score
- 21
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Aug 2026, 2 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microwind/ai-skills/ddd-vs-mvc)