Canonical: https://weaveos.com/zh-cn/glossary/interface-segregation

[首页](https://weaveos.com/zh-cn)/[术语表](https://weaveos.com/zh-cn/glossary)/[Code quality and technical debt](https://weaveos.com/zh-cn/glossary/category/code-quality-technical-debt)/接口隔离

[Code quality and technical debt](https://weaveos.com/zh-cn/glossary/category/code-quality-technical-debt)

# 接口隔离

也称为 接口隔离, 软件工程中的接口隔离

作者：Weave发布于 2026年9月10日1 分钟阅读

## 定义

一种倾向于专注接口的设计原则，使客户端仅依赖于它们所使用的功能。

在本页中

1. [定义](https://weaveos.com/zh-cn/glossary/interface-segregation#definition)
2. [它的含义](https://weaveos.com/zh-cn/glossary/interface-segregation#article-section)
3. [示例](https://weaveos.com/zh-cn/glossary/interface-segregation#article-section-2)
4. [局限性](https://weaveos.com/zh-cn/glossary/interface-segregation#article-section-3)
5. [如何使用该信号](https://weaveos.com/zh-cn/glossary/interface-segregation#article-section-4)
6. [这与 Weave 有何关系](https://weaveos.com/zh-cn/glossary/interface-segregation#weave)
7. [来源](https://weaveos.com/zh-cn/glossary/interface-segregation#sources)
8. [相关术语](https://weaveos.com/zh-cn/glossary/interface-segregation#related)

## 它的含义

接口隔离减少了客户端了解与其工作无关的方法的义务。更小、角色特定的契约可以降低耦合，并使替换和测试更容易。该原则关注的是有用的责任边界，而不是最大化接口数量。

## 示例

文档导出器需要 `write` 和 `close`，但它接收了一个带有删除、索引和管理方法的大型存储接口。专注的写入者契约缩小了导出程序所能依赖的范围。

## 局限性

过度隔离可能会制造一个微小抽象的迷宫，并使常见的工作流更难发现。当操作形成一个连贯的能力时，共享接口可能是合适的。根据客户需求和变更模式进行判断。

## 如何使用该信号

优先选择符合客户端职责的契约，同时避免使用那些让通用路径难以发现的微小接口。

Weave 可以帮助比较接口重构与审查规模及返工情况。让团队掌握设计决策，使用 Weave 查看更窄的契约是否减少了交付摩擦。

## 这与 Weave 有何关系

Weave 可以帮助比较接口重构与审查规模及返工情况。让团队掌握设计决策，使用 Weave 查看更窄的契约是否减少了交付摩擦。

[探索 工程智能](https://weaveos.com/zh-cn/products/engineering-intelligence)

## 来源与延伸阅读

1. [SonarSource code metrics and analysis documentation](https://docs.sonarsource.com/sonarqube-server/latest/user-guide/code-metrics/metrics-definition/)

## 相关术语

### [工程分析](https://weaveos.com/zh-cn/glossary/engineering-analytics)

[工程分析衡量什么，如何解读交付和代码数据，以及 Weave 如何将工程活动与有用的成果联系起来。](https://weaveos.com/zh-cn/glossary/engineering-analytics)

### [开发者生产力](https://weaveos.com/zh-cn/glossary/developer-productivity)

[了解开发者生产力，为何活动计数是不完整的，以及如何评估交付、质量和人工智能辅助的工程工作。](https://weaveos.com/zh-cn/glossary/developer-productivity)
