|
Posted by Oli Filth on 10/31/65 11:33
FluffyCat wrote:
> New on November 29, 2005 for www.FluffyCat.com PHP 5 Design Pattern
> Examples - the Command Pattern.
>
> Since you all enjoyed the Visitor Pattern so much yesterday, today I
> have the Command Pattern for you. This one is pretty straight
> forward. In the Command Pattern an object encapsulates everything
> needed to execute a method in another object.
>
> http://www.fluffycat.com/SDCMSv2/PHP-Design-Patterns-Command/
Firstly, a typo - you have references to $plainVisitor, which is from
another example!!
Also, I'd recommend changing the name of BookCommandee to Book, because
that's all it is sematically.
Also, it would be more demonstrative if the logic to insert/remove the
stars was in the BookStarsOnCommand and BookStarsOffCommand classes,
i.e. remove BookCommandee::setStarsOn() and
BookCommandee::setStarsOff().
Otherwise, it begs the question "why not just call $book->setStarsOn()
from testCommand.php?".
--
Oli
Navigation:
[Reply to this message]
|