SOLID (object-oriented design)

本文介绍了SOLID原则,这是由Robert C. Martin提出的面向对象编程和设计的基本原则集合。这五个原则分别是单一职责原则(SRP)、开放封闭原则(OCP)、里氏替换原则(LSP)、接口隔离原则(ISP)和依赖倒置原则(DIP),它们有助于创建易于维护和扩展的软件系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In computer programming, SOLID (single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion) is a mnemonic acronym introduced by Michael Feathers for the “first five principles” named by Robert C. Martin[1][2] in the early 2000s[3] that stands for five basic principles of object-oriented programming and design. The intention is that these principles, when applied together, will make it more likely that a programmer will create a system that is easy to maintain and extend over time.[3] The principles of SOLID are guidelines that can be applied while working on software to remove code smells by providing a framework through which the programmer may refactor the software’s source code until it is both legible and extensible. It is part of an overall strategy of agile and Adaptive Software Development.[3]

InitialStands forConcept
SSRP[4]Single responsibility principle a class should have only a single responsibility (i.e. only one potential change in the software’s specification should be able to affect the specification of the class)
OOCP[5]Open/closed principle “software entities … should be open for extension, but closed for modification.”
LLSP[6]Liskov substitution principle “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.” See also design by contract.
IISP[7]Interface segregation principle “many client-specific interfaces are better than one general-purpose interface.”[8]
DDIP[9]Dependency inversion principle one should “depend upon abstractions, [not] concretions.”[8]

https://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29

YAGNI:
https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值