← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 1874.i

小接口要隐藏实现细节

理解等级:高级

接口应符合调用者预期,尽量交换必要信息,提供可组合原语,并以一致名字、参数顺序和错误约定降低误用。统一访问使调用者无需知道值来自缓存、计算还是远端。越多实现细节被暴露,越难独立演化;简单接口也不能省掉调用者安全使用所需的语义。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 软件接口 · 查看原书依据

      Avoid leaking implementation details through the interface. A resource should be accessible to its actors in the same way regardless of how they are implemented. An actor should be unaware, for example, whether a value is returned from a cache, from a computation, or from a fresh fetch of the value from some external source.

    参考来源

    - 位置:《Software Architecture in Practice, 4th Edition》第15章《软件接口》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch15.html) - 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。 - 原始内容:Avoid leaking implementation details through the interface. A resource should be accessible to its actors in the same way regardless of how they are implemented. An actor should be unaware, for example, whether a value is returned from a cache, from a computation, or from a fresh fetch of the value from some external source.