尖叫架构与用例意图
了解为什么整洁架构应该让应用领域一目了然,而不是让人首先看到它所使用的框架。
尖叫架构与用例意图 是 CoddyKit 上的免费 Clean Architecture & Design Patterns in Practice 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Clean Architecture & Design Patterns in Practice 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Clean Architecture & Design Patterns in Practice 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
What Does Your Structure Say?
Open a typical project and you often see folders named controllers, models, views. That structure shouts the framework, not the purpose.
Robert C. Martin called the alternative Screaming Architecture: the top-level structure should scream what the system does.
Architecture Is About Intent
Just as a building plan screams library or hospital, a healthcare app should scream patient scheduling and billing — not Spring or React.
The use cases are the heart of the system, so they should be the most visible thing.
Framework-Centric Structure
A framework-driven layout buries the domain.
src/
controllers/
repositories/
entities/
config/Intent-Revealing Structure
A use-case-driven layout puts the domain first.
src/
scheduling/
billing/
patient_records/
prescriptions/Frameworks Are Details
This reinforces a core Clean Architecture idea: the framework is a delivery mechanism, a detail you plug in.
Your business rules should not depend on whether you chose one web framework over another. The structure should make that independence obvious.
Deferring Decisions
When the domain leads the structure, you can defer infrastructure choices.
You can begin building and even testing core use cases before committing to a database or web framework, because those live at the edges.
Testability Reveals Intent
A telltale sign of screaming architecture: you can test all your use cases without the framework, the UI, or the database running.
If your tests need a web server to verify a business rule, the framework has leaked into the core.
Mapping Use Cases to Modules
Each major use case or feature becomes a clearly named module or package. Inside it live the entities and interactors that implement that capability.
scheduling/
ScheduleAppointment.java
CancelAppointment.java
Appointment.javaThe Plugin Mindset
Think of the web, the database, and external services as plugins to your application core.
The core defines the rules; the plugins adapt the outside world to those rules. This mindset directly produces screaming structure.
Common Pushback
Teams sometimes resist because frameworks ship with conventional folder layouts.
You can still honor those conventions at the edges while organizing your core by domain. The goal is that the most important code is the most visible.
A Quick Self-Test
- Can a newcomer guess what the app does from the folder names?
- Can you delay choosing a database?
- Can use cases be tested without the framework?
Three yeses mean your architecture is screaming the right thing.
Quick Check
Test your understanding of screaming architecture.
Recap
You learned that a clean structure should scream its domain.
- Organize by use case, not by framework role.
- Frameworks and databases are deferrable details.
- If use cases test without the framework, intent leads the design.
常见问题解答
「尖叫架构与用例意图」课时是免费的吗?
是的 — 「尖叫架构与用例意图」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Clean Architecture & Design Patterns in Practice 课程的其余内容,请升级到 CoddyKit PRO。 Clean Architecture & Design Patterns in Practice 课程共包含 4 节课。
「尖叫架构与用例意图」这节课中我会学到什么?
了解为什么整洁架构应该让应用领域一目了然,而不是让人首先看到它所使用的框架。 你通过在浏览器中直接运行的动手代码来练习 Clean Architecture & Design Patterns in Practice,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Clean Architecture & Design Patterns in Practice 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Clean Architecture & Design Patterns in Practice 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。
「尖叫架构与用例意图」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Clean Architecture & Design Patterns in Practice 课中编写并运行代码吗?
能。每节 Clean Architecture & Design Patterns in Practice 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。