设计原则 Design Principle
Design Principle设计原则
最近由于碰到要参与设计一个音频处理系统,有人提议用一个大的全局变量结构体来做状态信息交流的地方,引起了我对设计一个系统的思考,于是找到了如下资料,当然,关于这个系统也是有待验证,不能说全局变量就是不好,因为这个系统并不会并发执行,而且资源充足。 我反正有点疑虑,但是会继续验证。
以下为Gof的六大设计原则,出自《设计模式》。
Single Responsibility Principle -SRP
There should never be more than one reason for a class to change.
Open Closed Principle – OCP
Software entities like classes, modules and functions should be open for extension but closed for modifications.
Liskov Substitution Principle - LSP
Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
Least Knowledge Principle - LKP
Only talk to you immediate friends.
Interface Segregation Principle - ISP
The dependency of one class to another one should depend on the smallest possible interface.
Dependence Inversion Principle - DIP
High level modules should not depends upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions.
剩下的个人认为是非常简单实用。
Don't repeat yourself – DRY
Keep it simple and stupid – KISS
High Cohesion and Low Coupling – HCLC
Design by Contract - DBC
You aren't gonna need it - YAGNI
参考的文章:
http://www.cnblogs.com/areliang/archive/2006/03/07/345111.html
设计原则 Design Principle的更多相关文章
- Design Principle vs Design Pattern 设计原则 vs 设计模式
Design Principle vs Design Pattern设计原则 vs 设计模式 来源:https://www.tutorialsteacher.com/articles/differen ...
- 设计模式-设计原则(Design Principle)
本文由@呆代待殆原创,转载请注明出处. 写在前面:所谓设计原则并不是一定要遵守的法则,只是一种建议,因为保持这些原则本身会有一定代价,若是这些代价超过了带来的好处就得不偿失了,所以一切还是以简单为准. ...
- 设计原则:开-闭原则(Open-Closed Principle, OCP)
开-闭原则就是软件实体应当对扩展开放,对修改关闭.(Software entities should be open for extension,but closed for modification ...
- 面象对象设计原则之六:迪米特原则(LeastKnowledge Principle, LKP)
迪米特法则来自于1987年美国东北大学(Northeastern University)一个名为“Demeter”的研究项目.迪米特法则又称为最少知识原则(LeastKnowledge Princip ...
- 面象对象设计原则之五:依赖倒置原则(The Dependency Inversion Principle,DIP)
如果说开闭原则是面向对象设计的目标的话,那么依赖倒转原则就是面向对象设计的主要实现机制之一,它是系统抽象化的具体实现.依赖倒转原则是Robert C. Martin在1996年为“C++Reporte ...
- 面象对象设计原则之二:开放封闭原则(Open-Closed Principle, OCP)
开闭原则是面向对象的可复用设计的第一块基石,它是最重要的面向对象设计原则.开闭原则由Bertrand Meyer于1988年提出,其定义如下: 开闭原则(Open-Closed Principle, ...
- 面象对象设计原则之一:单一职责原则(Single Responsibility Principle, SRP)
单一职责原则是最简单的面向对象设计原则,它用于控制类的粒度大小.单一职责原则定义如下:单一职责原则(Single Responsibility Principle, SRP):一个类只负责一个功能领域 ...
- 面向对象设计原则 开放封闭原则(Open Closed Principle)
开放封闭原则(OCP,Open Closed Principle) 开放封闭原则是所有面向对象原则的核心. 软件设计本身所追求的目标就是封装变化.降低耦合,而开放封闭原则正是对这一目标的最直接体现. ...
- Android Wear - Design Principles for Android Wear(设计原则)
---------------------------------------------------------------------------------------------------- ...
随机推荐
- 结构体 typedef关键字
1 结构体 #include <iostream> #include <cstring> using namespace std; void printBook( struct ...
- CQRS学习——Cqrs补丁,async实验以及实现[其二]
实验——async什么时候提高吞吐 async是一个语法糖,用来简化异步编程,主要是让异步编程在书写上接近于同步编程.总的来收,在await的时候,相当于附加上了一个.ContinueWith(). ...
- hdu 3449
有依赖的背包,转化成01背包来做: #include<iostream> #include<cstdio> #include<cstring> #include&l ...
- hdu 4454 Stealing a Cake 三分法
很容易想到三分法求解,不过要分别在0-pi,pi-2pi进行三分. 另外也可以直接暴力枚举…… 代码如下: #include<iostream> #include<stdio.h&g ...
- C# 模拟POST提交文件
http://blog.csdn.net/hellowjwang/article/details/19975635 public class HttpPost { /// <summary> ...
- 敏捷开发系列之旅 第二站(走近XP极限编程)
http://blog.csdn.net/happylee6688/article/details/21551065 上篇文章,我们探讨了什么是敏捷开发,以及敏捷开发的方法学.在这篇文章中,我们将继续 ...
- 有关PHP 10条有用的建议
1.使用ip2long() 和long2ip()函数来把IP地址转化成整型存储到数据库里. 这种方法把存储空间降到了接近四分之一(char(15)的15个字节对整形的4个字节),计算一个特定的地址是不 ...
- Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04
摘自: http://www.cnblogs.com/kinglau/p/3796164.html http://www.powerxing.com/install-hadoop/ 当开始着手实践 H ...
- poj 1836 Alignment(dp)
题目:http://poj.org/problem?id=1836 题意:最长上升子序列问题, 站队,求踢出最少的人数后,使得队列里的人都能看到 左边的无穷远处 或者 右边的无穷远处. 代码O(n^2 ...
- 最小生成树(kruskal模版 模板)
题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2144&cid=1186 #include<stdio.h> #incl ...