设计原则 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(设计原则)
---------------------------------------------------------------------------------------------------- ...
随机推荐
- ZOJ Problem Set - 1002(DFS)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1002 题意:给出一个n,有n*n大小的城市,(.)表示空地,从碉堡(O)射 ...
- 第一章、关于SQL Server数据库的备份和还原(sp_addumpdevice、backup、Restore)
在sql server数据库中,备份和还原都只能在服务器上进行,备份的数据文件在服务器上,还原的数据文件也只能在服务器上,当在非服务器的机器上启动sql server客户端的时候,也可以通过该客户端来 ...
- http://doc.okbase.net/congcong68/archive/112508.html
http://doc.okbase.net/congcong68/archive/112508.html
- HeadFirst设计模式之状态模式
一. 1. 2.The State Pattern allows an object to alter its behavior when its internal state changes. Th ...
- MyBatis的动态SQL操作--更新
更新条件不确定,需要根据具体的情况生成sql语句. id是主键,一般不会去更新. 1.只更新name的值 update student set name = ? where id = ? 2.只更新s ...
- python脚本工具 - 3 目录遍历
遍历系统中某一目录下的所有文件名 #! /usr/bin/python # coding:utf-8 import os def dirList(path): filelist = os.listdi ...
- HDFS的命令行操作
1.namenode –format:格式化DFS 文件系统 2.secondaryNameNode: 运行DFS的 SecondaryNameNode 进程 hadoop secondaryname ...
- ISE综合后得到的RTL图如何与硬件对应起来,怎么知道每个element的功能
2013-06-23 21:34:03 要知道“我写的这段代码会综合成什么样的电路呢”,就要搞清楚RTL图中每个模块的功能,从而将代码与硬件对应,判断综合后的电路是否与预期的一致.如何做到? 之前查了 ...
- linux下进程相关操作
一.定义和理解 狭义定义:进程是正在运行的程序的实例. 广义定义:进程是一个具有一定独立功能的程序关于某个数据集合的一次运行活动. 进程的概念主要有两点: 第一,进程是一个实体.每一个进程都有它自己的 ...
- poj 3007 Organize Your Train part II(二叉排序树)
题目:http://poj.org/problem?id=3007 题意:按照图示的改变字符串,问有多少种..字符串.. 思路:分几种排序的方法,,刚开始用map 超时(map效率不高啊..),后来搜 ...