一些设计原则的汇总

几个简单易行的原则

  1. DRY. don’t repeat yourself.

  2. KISS. Keep it simple, stupid

  3. YAGNI. You ain't gonna need it

class design principles

SOLID(wiki, article): SRP, OCP, LSP, ISP, DIP.

  • SRP(wiki, pdf): Single responsibility principle. A class should have one, and only one, reason to change.

  • OCP(wiki, pdf): Open/closed principle. You should be able to extend a classes behavior, without modifying it.

  • LSP(wiki, pdf): Liskov substitution principle. Derived classes must be substitutable for their base classes.

  • ISP(wiki, pdf): Interface segregation principle. Make fine grained interfaces that are client specific.

  • DIP(wiki, pdf): Dependency inversion principle. Depend on abstractions, not on concretions.

package cohesion principles

  • REP(pdf): The Release Reuse Equivalency Principle. The granule of reuse is the granule of release.

  • CCP(pdf): The Common Closure Principle. Classes that change together are packaged together.

  • CRP(pdf): The Common Reuse Principle. Classes that are used together are packaged together.

packages coupling principles

  • ADP(pdf): The Acyclic Dependencies Principle. The dependency graph of packages must have no cycles.

  • SDP(pdf): The Stable Dependencies Principle. Depend in the direction of stability.

  • SAP(pdf): The Stable Abstractions Principle. Abstractness increases with stability.

架构原则

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值