知识卡片

问题卡 · 1765.h

以业务动作隐藏存储

理解等级:中级

若客户端直接依赖存储引擎和查询语法,更换底层技术就容易破坏接口。

数据接口应承诺“更新客户”“查逾期账单”等业务能力,避免要求调用方提交数据库连接、表结构或存储引擎查询。外部表单表达客户需要的输入,由内部转换成存储操作;这样更换存储技术时可以保留接口承诺。

查询也优先提供具名链接或参数化表单。新增必填参数会增加兼容负担;有合理默认值时可保持可选。专门建设查询引擎本身,才是需要公开数据语言的另一种职责。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 分布式数据 · 查看原书依据

      As a rule, it is good idea to hide the data storage technology from your API consumers. They should not know whether you are using SQL-based tech, GraphQL, or simple filed-based storage. Ideally, you should design your interfaces in a way that allows you to change the underlying data storage without adversely affecting existing API consumers.

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第6章《分布式数据》§6.1(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch06.xhtml) - 结论依据:原文以数据接口应承诺“更新客户”“查逾期账单”等业务能力,避免要求调用方提交数据库连接、表结构或存储引擎查询的方式说明该用途;同节示例与讨论补充了卡内条件和边界。 - 原始内容:As a rule, it is good idea to hide the data storage technology from your API consumers. They should not know whether you are using SQL-based tech, GraphQL, or simple filed-based storage. Ideally, you should design your interfaces in a way that allows you to change the underlying data storage without adversely affecting existing API consumers.