solid原则

本文探讨了SOLID设计原则在软件开发中的应用,重点讲解单一职责原则(SRP)、开放封闭原则(OC)、里氏替换原则(LSP)、接口隔离原则(ISP)和依赖倒置原则(DIP),并讨论了这些原则如何帮助限制变更的影响,实现模块化设计。

Tuo让我这周总结solid原则。在学校的时候主要学面向对象语言的时候会接触到solid之中的一些原则。但是到公司参加工作两个月以来用的开发语言主要用的是javascript(typed languege?functional languege?),对于solid原则感觉需求或者说是应用感觉是无从下手。

S - Single responsibility principle  /  evrey object or module..etc. should have one ,and only one reason to change

一开始理解这个原则的时候可能觉得一个类有越少的功能越好,但是查阅一些博客后找到了更准确的理解。这个原则的重点就是one reason to change。

In ohter words, Gather together the things that change for the same reasons. Seperate those things that changes for different reasons. I think the purpose of the principle is limiting the impact of changes.  Instead of being a one-way street to minimally sized classes,the SRP is actually proposing a balance point between aggregation and division.

 

O - Open closed priciple  /  open for extension close for modification

L - Liskov substitution principle  /  derived obj or types must be substitutable for their base

I - Interface segregation principle  /  make fine grained interfaces that are client specific

D - Dependency inversion principle  /  Detail must relay on abstractions

 

这是一个我的大学学长发的朋友圈印象很深刻。当你设计模式与实际问题结合的时候才会有更深入的了解。

转载于:https://www.cnblogs.com/ybleeho/p/9785421.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值