07 2017 档案

摘要:中介者模式 中介者模式包装了一系列对象相互作用的方式,使得这些对象不必相互明显作用,从而使它们可以松散偶合。当某些对象之间的作用发生改变时,不会立即影响其他的一些对象之间的作用,保证这些作用可以彼此独立的变化。 中介者模式添加了第三方对象(称为中介者)来控制两个对象(称为 colleague)之间的 阅读全文
posted @ 2017-07-25 09:23 Bin_x 阅读(164) 评论(0) 推荐(0) 编辑
摘要:在面向对象程序设计中,迭代器模式是一种设计模式,其中迭代器用于遍历容器并访问容器的元素。迭代器模式将算法与容器解耦; 在某些情况下,算法是特定容器必需的,因此不能解耦。 阅读全文
posted @ 2017-07-21 14:19 Bin_x 阅读(243) 评论(0) 推荐(0) 编辑
摘要:_bulb = $bulb; } public function execute() { $this->_bulb->turnOn(); } public function undo() { $this->_bulb->turnOff(); } public function redo() { ... 阅读全文
posted @ 2017-07-19 09:23 Bin_x 阅读(136) 评论(0) 推荐(0) 编辑
摘要:next = $account; } public function canPay($amount) { return $this->balance >= $amount; } public function pay($amount) { if ($this->canPay($amount)) { echo ... 阅读全文
posted @ 2017-07-18 15:08 Bin_x 阅读(119) 评论(0) 推荐(0) 编辑
摘要:door = new Door(); } public function open($password) { if ($this->authenticate($password)) { $this->door->open(); } else { echo 'The password is wrong... 阅读全文
posted @ 2017-07-18 10:06 Bin_x 阅读(86) 评论(0) 推荐(0) 编辑

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