[php]php设计模式 Bridge (桥接模式)

摘要: 1 <?php 2 /** 3 * 桥接模式 4 * 5 * 将抽象部份与它实现部分分离,使用它们都可以有独立的变化 6 */ 7 abstractclass Implementor 8 { 9 abstractpublicfunction operation();10 }11 12 class ConcreteImplementorA extends Implementor13 {14 publicfunction operation()15 {16 echo"ConcreteImplementorA Operation<br/>";17 }18 }19 阅读全文
posted @ 2011-06-21 22:58 bluefrog 阅读(1574) 评论(0) 推荐(0)

[php]php设计模式 Proxy (代理模式)

摘要: 1 <?php 2 /** 3 * 代理模式 4 * 5 * 为其他对象提供一个代理以控制这个对象的访问 6 * 7 */ 8 interface Proxy 9 {10 publicfunction request();11 publicfunction display();12 }13 14 class RealSubject15 {16 publicfunction request()17 {18 echo"RealSubject request<br/>";19 }20 21 publicfunction display()22 {23 echo& 阅读全文
posted @ 2011-06-21 00:10 bluefrog 阅读(1474) 评论(0) 推荐(1)

[php]php设计模式 State (状态模式)

摘要: 1 <?php 2 /** 3 * 状态模式 4 * 5 * 允许一个对象在其内部状态改变时改变它的行为,对象看起来似乎修改了它所属的类 6 * 7 */ 8 interface State 9 {10 publicfunction handle($state);11 publicfunction display();12 }13 14 class Context15 {16 private$_state=null;17 18 publicfunction __construct($state)19 {20 $this->setState($state);21 }22... 阅读全文
posted @ 2011-06-21 00:08 bluefrog 阅读(1315) 评论(0) 推荐(0)