A Brief introduction:
Command mode: The command pattern is divided into "requestor of the Command" and "Implementation of the Command". Make the request for the command and the implementation complete understanding decoupling.
Two Example:
Cook = $cook; Public Function Execute () {$this->cook->meal (); }}class Drinkcommand implements command{private $cook; Public function __construct (Cook $cook) {$this->cook = $cook; Public Function Execute () {$this->cook->drink (); }}/* * Simulation class */class cookcontrol{private $mealCommand; Private $drinkCommand; Public Function AddCommand (command $mealCommand, command $drinkCommand) {$this->mealcommand = $mealCommand; $this->drinkcommand = $drinkCommand; Public Function Callmeal () {$this->mealcommand->execute (); Public Function Calldrink () {$this->drinkcommand->execute (); }} $control = new Cookcontrol (), $cook = new Cook; $mealCommand = new Mealcommand ($cook); $drinkCommand = new Drinkcommand ($co OK); $control->addcommand ($mealCommand, $drinkCommand); $control->callmeal (); $control->calldrink ();
Three Principle of Use:
1. Refine the business process according to the business process. Step-by-step abstraction until ' appropriate '.
2. The classification of responsibilities requires attention.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the (vi) object-oriented design principles of the second, including the aspects of the content, I hope to be interested in the PHP tutorial friends helpful.