Software Design Principle

本文阐述了软件设计中至关重要的五大原则:单一职责原则(SRP)、接口隔离原则(ISP)、依赖倒置原则(DIP)、开放封闭原则(OCP)及里氏替换原则(LSP),并解释了这些原则如何帮助开发者创建更灵活、可维护的系统。

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

There are lots of design patterns,but the most important thing you should know the the principle of design.All of the patterns are followed those principles.

1.SRP -  Single Responsible Principle

One class should has the single responsible, we should avoid the same responsibiltes spreaded into defferent classed and avoid one class do to much responsibility.

2.ISP - Interface Segregation Principle

If one class has reference to anther one, it's better segregate them by interface rather than inheritance because the subclass sometimes don't need  some functions in base class.

3.DIP - Dependence Inversion Principle

Programming on the interface rather than the concrete  class.The high level class communicates with the lower level with interface.As the interface is abstract  so it  relative stable.

4.OCP - Open  Closed Principle

Open for the extension and closed for the modify. A class should be opened and extensible, but when you want to extend the function of this class, it's better don't modify the exist class or you shouldn't affact exist function.

5.LSP - Liskov  Substitution Principle

sub types must be substitutable for their base types.

 

Above all,Pls understand those principle carefullly, and you will get more discoveries and surprises.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值