SOLID Principles

本文介绍了面向对象编程(OOP)中的五个核心原则:单一职责原则强调每个类只负责一项功能;开放封闭原则提倡通过扩展而非修改现有代码的方式进行更新;里氏替换原则确保子类可以替换父类且不会引发错误;接口隔离原则建议将接口拆分为更小更具体的接口,避免实现不必要的方法;依赖倒置原则指出程序应依赖抽象接口而非具体实现。

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

It’s a very important principle in OOP.
Single responsibility : every single class should just do one thing
Open closed: extension but not modification
Liskov substitution: any instance in any place, we can just replace it with it’s subclass instance without causing any trouble
Interface segregation: interface should be divided into smaller and more specific interface, so that any class who implement this interface won’t be forced to implement methods he doesn;t need it at all.
Dependency inversion: program needs to rely on the abstract interface instead of any specific implementation.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值