《Agile Software Development》关于Design Principle阅读笔记

 Design Principle:

1、SRP:The Single-Responsibility Principle

     A class should have only one reason to change.

how to use:

Depends how the applicaton is changing.It is not wise to apply the SRP,or any other principle for that matter,if there is no symptom.

心得:SRP的使用存在一个平衡,灵活性和复杂性之间的平衡,是否要按职责分出类来取决于实际需求,有必要分出职责的时候就使用SRP。Rigidity vs Needless Complexity

 

2、OCP:The Open-Closed Principle

     Software entities(class,modules,function,etc) should be open for extension,but closed for modification.

how to use:

Abstraction is the Key!

   When a single change to a program results in a cascade of changes to dependent modules,the design smells of Reigidy.the OCP advises us to refactor the system so that further changes of that kind will not cause more modifications.If the OCP is appled well,then further changes of that kind are achieved by adding new code ,not by changing old code that already works.

  Since closure cannot be complete ,it must be strategic.That is the designer must choose the kinds of changes against which to close his design.

心得:close是不可能完全的,必须懂得预料变化,设计出应对可能变化的Closure。但是这不容易,设计初期大多时候靠猜,有很大的运气成分,要等到变化来的时候才有结果,不要拘泥于形式。

几大方法:1、Fool me once 吃一堑,长一智,积累设计经验 2、Stimulating Change 主动刺激变化产生,早发现,早治疗 3、Using Abstraction to Gain Explicit Closure 运用抽象

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值