摘要: 1 sea = $sea;24 $this->plains = $plains;25 $this->forest = $forest;26 }27 28 function getSea(){29 return clone $this->sea;30 }31 function getPlains(){32 return clone $this->plains;33 }34 function getForest(){35 return clone $this->... 阅读全文
posted @ 2014-03-20 18:14 jami918 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 上一节理解了工厂模式。其代码原理如下:<?phpabstract class ApptEncoder{ abstract function encode();}class BloggsApptEncoder extends ApptEncoder{ function encode(){ ... 阅读全文
posted @ 2014-03-20 17:36 jami918 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 工厂方法模式 把 创造者类 和要生产的 产品类 分离。创建者是一个工厂类,其定义了产品生产的类方法。一般情况下,创建者类的每个子类实例化一个相应的产品子类。下面是单个产品的实现代码:<?phpabstract class ApptEncoder{ abstract function encode();}class BloggsApptEncoder extends ApptEncoder{ function encode(){ return "data encode farmat"; }}abstract class CommsManager{ abstr... 阅读全文
posted @ 2014-03-20 17:23 jami918 阅读(190) 评论(0) 推荐(1) 编辑