V2EX  ›  英汉词典

Single Responsibility Principle

释义 Definition

单一职责原则(SRP):软件设计原则之一,指一个类、模块或函数应只承担一种“职责”(一个引起其变化的原因),从而降低耦合、提高可读性与可维护性。它也是 SOLID 五大面向对象设计原则中的 “S”。

发音 Pronunciation (IPA)

/ˌsɪŋɡəl rɪˌspɑːnsəˈbɪləti ˈprɪnsəpəl/

例句 Examples

A class should follow the single responsibility principle.
一个类应该遵循单一职责原则。

By applying the single responsibility principle, we separated validation from data persistence, which reduced bugs and made refactoring safer.
通过应用单一职责原则,我们把校验逻辑与数据持久化分离开来,从而减少了缺陷,也让重构更安全。

词源 Etymology

“Single responsibility principle”由 responsibility(职责)principle(原则) 组合而成,表达“只承担一种职责的设计原则”。该表述在软件工程语境中常与 Robert C. Martin(Uncle Bob) 的 SOLID 原则体系一起传播并被广泛引用,用来强调“变化原因要单一、关注点要分离”。

相关词 Related Words

文学与经典作品 Literary / Notable Works

  • Agile Software Development, Principles, Patterns, and Practices — Robert C. Martin
  • Clean Code: A Handbook of Agile Software Craftsmanship — Robert C. Martin
  • Clean Architecture: A Craftsman’s Guide to Software Structure and Design — Robert C. Martin
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   946 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 17:46 · PVG 01:46 · LAX 09:46 · JFK 12:46
♥ Do have faith in what you're doing.