知识卡片

普通读书笔记卡 · 3331.f

新服务先定义消费者契约

理解等级:高级

新服务先从消费者需要的业务能力定义契约,再设计内部表与代码。若直接把数据库表列映射为 API 字段,公开接口就泄漏存储模型,未来改库会迫使消费者迁移。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Principles of Software Architecture Modernization》第6章《Principles of Proper Services》(源文件:`_epub-src/OPS/ch06.xhtml`,归一化正文 [29532:33773)) - 结论依据:原文建议新服务采用契约先行,并把按表与列暴露接口称为 remote views 反模式。 - 原始内容:Imagine building a service on top of a database with 3 tables and 10 columns on each table, and to you it makes sense to have a contract with 3 operations associated with each table and 10 parameters, with each parameter named after a column.