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