知识卡片
API用规范隐藏实现
API 将实现细节藏在可理解的契约之后。规范不仅给出类型,还要约定信息交换的行为语义,消费者才能据此调用或生成适配代码。接口能否支持外部集成,取决于这些约定是否足以让双方独立实现;单有传输格式不足以形成可靠契约。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
An API represents an abstraction of the underlying implementation. An API is represented by a specification that introduces types. Developers can understand the specifications and use tooling to generate code in multiple languages to implement an API consumer (software that consumes an API). An API has defined semantics or behavior to effectively model the exchange of information.
参考来源
- 位置:《Mastering API Architecture》导言《Introduction》之《A Brief Introduction to APIs》(源文件:_epub-src/OEBPS/introduction01.xhtml)
- 结论依据:原文的 API 定义同时包含实现抽象、引入类型的规范与定义清楚的行为语义,并把它们联系到消费者实现及第三方集成。
- 原始内容:An API represents an abstraction of the underlying implementation. An API is represented by a specification that introduces types. Developers can understand the specifications and use tooling to generate code in multiple languages to implement an API consumer (software that consumes an API). An API has defined semantics or behavior to effectively model the exchange of information.