1.6 Principle:Layering

Layer k+1

⬆⬇data

Layer k

⬆⬇data

Layer k - 1

layer只和上下层的layer交流,下层layer为上层提供了well-defined service,各layer可以随着时间改进而不影响其他层

  1. Layers are functional components.

    层是功能组件。

  2. Layers communicate sequentially with the layers above and below.

    层与上面和下面的层按顺序通信。

  3. Each layer provides a well-defined service to the layer above,using the services provided by layers below and its own private processing.

    每个层使用下面层提供的服务和它自己的私有处理,为上面的层提供定义良好的服务。

举例

edit

⬇Source code

compile(词法分析、解析、预处理、代码生成和优化)

⬇Object code

link(把编译文件和libraries link给起来)

⬇Executable

execute

有时必须打破 layer: 跨界优化,但是丢失了灵活性

总结

分层的原因 1. Modularity 2. Well defined service 3. Reuse 4. Separation of concerns 5. Continuous improvement

  1. 只有 Layer communication system 如 Internet 特有的 peer-to-peer communications

  2. 模块化

  3. 为上层定义良好的服务

  4. 重用

  5. 关注点分离,减少复杂度

  6. 持续改进

  7. 对等通信,我和你用的layer system是一样的。

    只有 Layer communication system 如 Internet 特有的

Last updated

Was this helpful?