整洁架构读书笔记(Clean Architecture)

本文是Robert C Martin提出的Clean Architecture的读书笔记,介绍了整洁架构的核心原则——依赖规则,以及实体、用例、接口适配器、框架和驱动等组件。通过分层设计,实现业务规则与实现细节的分离,确保系统的可测试性、UI独立性和数据库独立性。文中还探讨了数据如何在各层间流动,并强调了避免外部依赖的原则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

又称干净的架构The Clean Architecture,这是著名软件工程大师Robert C Martin提出的一种架构整洁清晰之道,也是当前各种语言开发的目标架构。干净、清晰、整洁的架构应该只包含单向的依赖关系,这样才可以在逻辑上形成一种向上的抽象系统。

我们经常听说过如下各种架构:

六边形架构Hexagonal Architecture (也称为 端口和适配器) 这是由Alistair Cockburn 提出,被Steve Freeman和 Nat Pryce在他们的书籍Growing Object Oriented Software中采取的。
Onion Architecture 作者Jeffrey Palermo
Screaming Architecture Bob大叔
DCI 由James Coplien和Trygve Reenskaug推动
BCE Ivar Jacobson在他的书籍Object Oriented Software Engineering: A Use-Case Driven Approach提出
虽然这些架构在细节上都略有不同,但他们都非常相似。它们都具有相同的目标,那就是分离关注。他们都通过软件分层来实现这种分离。至少有一个层代表业务规则,而另一个层用于接口。

这些架构产生的系统特点是:

独立的框架. 这样的架构并不依赖与应用软件的具体库包,这样可以将框架作为工具,而不必将你的系统都胡乱混合在一起。
可测试. 业务规则能够在没有UI和数据库 或Web服务器的情况下被测试。
UI的独立性. UI改变变得容易,不必改变系统的其余部分,一个Web UI能被一个控制台或专门的图形UI替代, 这些读不必更改业务核心规则。
数据库的独立性. 你能够在Oracle或SQL Server Mongo, BigTable, CouchDB,或之间切换, . 你的业务规则不会和数据库绑定
独立的外部代理,其实你的业务规则可以对其外面的技术世界毫无所知,比如是否使用了MVC或DCI都可以不关心。
这种干净的架构图如下:

Practical Software Architecture Solutions from the Legendary Robert C. Martin (“Uncle Bob”), , By applying universal rules of software architecture, you can dramatically improve developer productivity throughout the life of any software system. Now, building upon the success of his best-selling books Clean Code and The Clean Coder, legendary software craftsman Robert C. Martin (“Uncle Bob”) reveals those rules and helps you apply them., , Martin’s Clean Architecture doesn’t merely present options. Drawing on over a half-century of experience in software environments of every imaginable type, Martin tells you what choices to make and why they are critical to your success. As you’ve come to expect from Uncle Bob, this book is packed with direct, no-nonsense solutions for the real challenges you’ll face—the ones that will make or break your projects., Learn what software architects need to achieve—and core disciplines and practices for achieving it, Master essential software design principles for addressing function, component separation, and data management, See how programming paradigms impose discipline by restricting what developers can do, Understand what’s critically important and what’s merely a “detail”, Implement optimal, high-level structures for web, database, thick-client, console, and embedded applications, Define appropriate boundaries and layers, and organize components and services, See why designs and architectures go wrong, and how to prevent (or fix) these failures, Clean Architecture is essential reading for every current or aspiring software architect, systems analyst, system designer, and software manager—and for every programmer who must execute someone else’s designs., Register your product at informit.com/register for convenient access to downloads, updates, and/or corrections as they become available.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值