知识卡片

普通读书笔记卡 · 3331.c

公开接口包含数据语义

理解等级:中级

公开方法的名称、入参、出参与数据格式都属于契约;返回值的拼写或格式即使类型仍是字符串,也可能破坏调用方。评审接口时不能只比较函数签名,还要核对可观察的数据语义。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Principles of Software Architecture Modernization》第2章《Anti-Patterns: Lack of Isolation》(源文件:`_epub-src/OPS/ch02.xhtml`,归一化正文 [46162:50347)) - 结论依据:原文逐项列出公开契约的名称、签名与数据格式,并以工作日字符串从 Monday 变为 MONDAY 说明格式变化可能破坏消费者。 - 原始内容:So, what is a contract? Anything public, composed of the following parts: A method Name. A method signature (parameters, input, and output). The format of the data. e.g. on getDayOfTheWeek is a string, but the format is written in English – i.e. Monday. If this String changes to MONDAY, this might break the consumers.