Skip to content

Commit 01260f0

Browse files
committed
feat: update articles
1 parent fd79ab7 commit 01260f0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

00~复杂性与设计原则/04.模块与拆分/抽象/深浅模块.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
最好的模块是那些提供强大功能但具有简单接口的模块。我用“深入”一词来描述这样的模块。为了形象化深度的概念,假设每个模块都由一个矩形表示。每个矩形的面积与模块实现的功能成比例。矩形的顶部边缘代表模块的接口;边缘的长度表示接口的复杂性。最好的模块很深:它们在简单的接口后隐藏了许多功能。深度模块是一个很好的抽象,因为其内部复杂性的很小一部分对其用户可见。
66

7-
![Deep and shallow modules.](https://s3.ax1x.com/2021/01/26/sX2Em4.png)
7+
![Deep and shallow modules.](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/uPic/aGNVhG0jB39o.png)
8+
9+
![Deep and shallow modules.](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/uPic/nNsSeh81uAfb.png)
810

911
深浅模块。最好的模块很深:它们允许通过简单的接口访问许多功能。浅层模块是具有相对复杂的接口的模块,但功能不多:它不会掩盖太多的复杂性。模块深度是考虑成本与收益的一种方式。模块提供的好处是其功能。模块的成本(就系统复杂性而言)是其接口。模块的接口代表了模块强加给系统其余部分的复杂性:接口越小越简单,引入的复杂性就越小。最好的模块是那些收益最大,成本最低的模块。接口不错,但更多或更大的接口不一定更好!
1012

0 commit comments

Comments
 (0)