知识卡片

普通读书笔记卡 · 1968.t.1

外部模型独立设计

理解等级:中级

API是独立接口,不应直接泄露服务的对象、数据库或过程模型。外部属性与操作须能独立成义;内部表拆分或字段改名时,由映射层维持原有契约。

ToDo的内部item/user可对外呈现为一个扁平todo集合,甚至把status单列资源;选择取决于交互需要而非存储表数。反规范化降低外部耦合,但服务必须自己安全完成多处写入、冲突及丢失更新控制,不能把扁平接口误当作自动获得一致性。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 超媒体服务 · 查看原书依据

      The best way to limit the possibility of exposing internal service details in the external API is to make sure the external interface is designed to exist apart from the internal service models. That means defining service API functionality on its own terms—not simply exposing the direct service code to the “outside world.”

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook》第5章《Hypermedia Services》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch05.xhtml,配方5.2) - 结论依据:原文以ToDo内部两种对象可外显为一种或三种资源说明外部模型无须复制内部模型。 - 原始内容:The best way to limit the possibility of exposing internal service details in the external API is to make sure the external interface is designed to exist apart from the internal service models. That means defining service API functionality on its own terms—not simply exposing the direct service code to the “outside world.”