CR的代码文本

all for learning about the world
  订阅 订阅  :: 管理

随笔分类 -  Pattern

摘要:ElementStateStateSet,一组stateConsole,管理一组Element代码有功能瑕疵。未实现activated元素间的互斥。View Code #include<iostream>#include<vector>#include<string>#include<map>inlinevoidline(std::stringstr){std::cout<<str<<std::endl;return;}enumStateID{WAITE,READY,ACTIVATED,MOVING,ZOOMING};st 阅读全文

posted @ 2011-04-08 18:21 mumuliang 阅读(1420) 评论(4) 推荐(0) 编辑

摘要:封装变化多用组合少用继承针对接口编程,不针对实现编程类应该对扩展开放,对修改关闭。 阅读全文

posted @ 2010-11-24 12:08 mumuliang 阅读(279) 评论(0) 推荐(0) 编辑

摘要:Observer C++实现Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#include<string>#include<iostream>#include<set>classIObserver;classISu... 阅读全文

posted @ 2010-11-24 10:13 mumuliang 阅读(492) 评论(0) 推荐(0) 编辑

摘要:Visitor模式Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#include<iostream>#include<string>classemp;classboss;classvisitor{public:visitor(... 阅读全文

posted @ 2010-11-23 17:03 mumuliang 阅读(908) 评论(4) 推荐(0) 编辑

摘要:1.创建型模式社会化的分工越来越细,自然在软件设计方面也是如此,因此对象的创建和对象的使用分开也就成为了必然趋势。因为对象的创建会消耗掉系统的很多资源,所以单独对对象的创建进行研究,从而能够高效地创建对象就是创建型模式要探讨的问题。1)单例模式(Singleton) 用来保证一个类只有一个实例。 《如何保证一个类只有一个实例(1)》 《如何保证一个类只有一个实例(2)》2)创建者模式(Builder)3)原型模式(Prototype)4)简单工厂模式(Simple Factory)5)工厂方法模式(Factory Method) 广泛的用来创建抽像接口的实例。6)抽象工厂模式(Abstract 阅读全文

posted @ 2010-08-29 11:21 mumuliang 阅读(279) 评论(0) 推荐(0) 编辑

摘要:疑问:“一个类只有一个实例”,这个命题本身就充满了矛盾。在C++中,类用来定义某一类型的抽象数据。类是规则,类的实例是按照规则生成的数据。类,就像数据库里某张基础表的表结构;类的实例就是其中的一条数据。如果一个类只有一个实例,也就是说这张表只有一条数据。这样的话,这个数据结构是不是有问题呢?这个数据抽象是不是没有做对? 阅读全文

posted @ 2009-11-06 13:05 mumuliang 阅读(470) 评论(0) 推荐(0) 编辑

摘要:方法:给类写一个静态函数static myClass* instance(){ static myClass ins; return &ins;};采用如下方式得到一个myClass的实例:myClass::instance(); 问题:众所周知,函数体内局部变量的生命周期是函数的存在期。在instance()消亡以后,内存中仍然存在一个static的myCalss实例ins。这在逻辑... 阅读全文

posted @ 2009-11-05 20:15 mumuliang 阅读(503) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示