上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: set(new offstate()); }}class offstate implements state{ public function show(){ echo '是关灯状态'; } public function handle($light){ $light->set(new ons... 阅读全文
posted @ 2014-10-31 11:59 tai君 阅读(443) 评论(0) 推荐(0) 编辑
摘要: createmitwo();$n->colorvoice();?> 阅读全文
posted @ 2014-10-30 16:59 tai君 阅读(188) 评论(0) 推荐(0) 编辑
摘要: "; } public function Method2() { echo "abstract Method2"; } public function Method3() { echo "abstract Method3"; } public function doSomeThing()//骨架... 阅读全文
posted @ 2014-10-27 17:23 tai君 阅读(377) 评论(0) 推荐(0) 编辑
摘要: state = $state; } public function getState(){ return $this->state; } public function copy(){ return clone $this;//浅拷贝 /* * 深拷贝 */// $tmp = s... 阅读全文
posted @ 2014-10-27 16:44 tai君 阅读(1438) 评论(0) 推荐(0) 编辑
摘要: createobj();$m->work();?> UML类图如下 阅读全文
posted @ 2014-10-27 15:25 tai君 阅读(221) 评论(0) 推荐(0) 编辑
摘要: a = new pjl(); } public function say(){ $this->a->say(); } public function ml(){ $this->a->ml(); }}$m = new wangpo();$m->say();echo "";$m->ml();?> ... 阅读全文
posted @ 2014-10-27 15:24 tai君 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 装饰模式 :装饰模式是在不必改变原类文件和使用继承的情况下,动态的扩展一个对象的功能。它是通过创建一个包装对象,也就是装饰来包裹真实的对象。装饰模式是一种 结构型模式主要角色 :(1)抽象构件(Component)角色:给出一个抽象接口,以规范准备接收附加责任的对象。(2)具体构件(Concrete... 阅读全文
posted @ 2014-10-24 15:26 tai君 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 最近工作很忙,为什么呢?因为双11快到了,作为电商公司的技术部苦逼程序员,又到了需求满天飞的时候了。赶上这几天项目提测,稍微空闲一点,决定好好写篇随笔。记录一下最近工作上的收获。 双11,我们组接到的一个需求是 抽奖转盘的开发。公司以前有着专门的抽奖系统的,但是现在听说是压力很大,而且以前的设... 阅读全文
posted @ 2014-10-21 17:07 tai君 阅读(748) 评论(2) 推荐(1) 编辑
摘要: 单一职责原则规定一个类应该只有一个发生变化的原因。通俗的说,即一个类只负责一项职责。我们一般在设计过程中,都会遵循这个原则。但是最后还是会写出违背单一职责原则的代码,为什么呢?因为会出现职责扩散。所谓职责扩散,就是因为某种原因,职责P被分化为粒度更细的职责P1和P2。我们一般事前是无法预知到职责会扩... 阅读全文
posted @ 2014-10-16 15:45 tai君 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 策略模式是有客户端自行实例化算法类的,而简单工厂模客户端只传参数,不关心对象的生成。结合两种模式,可以在使用策略模式的时候客户端不再生成算法的对象。修改策略模式的配置类即可。在之前策略模式基础上,修改如下cg = new category_a();break; case 'b': $... 阅读全文
posted @ 2014-10-15 17:40 tai君 阅读(884) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页