一些设计原则的汇总

几个简单易行的原则

  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.

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

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

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

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

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

package cohesion principles

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

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

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

packages coupling principles

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

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

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

架构原则

  1. GRASP. wiki

关键字:principle, pdf, wiki, classes

版权声明

本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部