← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 2313.e.5.f.10.b.3.k.1.a

替换要保持行为契约

理解等级:高级

里氏替换要求实现被替换后仍满足调用者原有契约,不能突然增加前置条件或削弱承诺。原书Push实现用kwargs要求额外device_token,会让同一调用在换实现后失败;接口签名相同不能证明可替换,应在共同契约或适配层处理渠道差异。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Design for Speed and Efficiency · 查看原书依据

      The Liskov Substitution Principle (LSP) states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program. In a serverless context, this principle can be applied to the design of function interfaces and the interaction between different services.

    参考来源

    - 位置:《Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…》第05章《Design for Speed and Efficiency》(来源项目book-sources;源文件:extracted/Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…/_epub-src/OPS/ch05.xhtml) - 结论依据:原文给出本卡对应定义或示例;里氏替换要求实现被替换后仍满足调用者原有契约,不能突然增加前置条件或削弱承诺。 对原文省略和过度承诺的限定是本卡显式纠正,不能反过来当作原书已证明。 - 原始内容:The Liskov Substitution Principle (LSP) states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program. In a serverless context, this principle can be applied to the design of function interfaces and the interaction between different services.