Do you know all the 25 php design patterns? The following code introduces the delegate mode (Delegation mode )? Php * delegate mode example *...
25 php typesDesign ModeDo you all know? The following code is used to introduceDelegation mode)
_ Object = new $ object ();} function addSong ($ location, $ title) {$ this-> _ songs [] = array ("location" => $ location, "title" =>$ title);} function getPlayList () {return $ this-> _ object-> getPlayList ($ this-> _ songs );}} class mp3PlayListDelegation {function getPlayList ($ songs) {$ aResult = array (); foreach ($ songs as $ key => $ item) {$ path = pathinfo ($ item ['location']); if (strtolower ($ item ['extension']) = "mp3 ") {$ aResult [] = $ item;} return $ aResult;} class rmvbPlayListDelegation {function getPlayList ($ songs) {$ aResult = array (); foreach ($ songs as $ key => $ item) {$ path = pathinfo ($ item ['location']); if (strtolower ($ item ['extension']) = "rmvb") {$ aResult [] = $ item;} return $ aResult; }}$ oMP3PlayList = new PlayList ("mp3 "); $ oMP3PlayList-> getPlayList (); $ oRMVBPlayList = new PlayList ("rmvb"); $ oRMVBPlayList-> getPlayList ();
Other related design patterns:
Memorandum mode (Memento mode)
Observer Mode (Observer mode)
Template Method mode)
Command mode)
Composite mode)
Enjoy the metadata mode (flyweight mode)
Strategy mode)
State mode)
Adapter mode)
Factory mode)
Prototype)
Appearance mode (facade mode)
Singleton mode)
Bridge Mode)
Decorator mode)
Abstract factory mode (abstract factory mode)
Builder mode (Builder mode)
Visitor mode (Visitor mode)
Interpreter mode (Interpreter mode)
Mediator mode)
Responsibility Chain mode (Chain Of Responsibility mode)
Proxy mode)
Iterator mode)
Data Access Object mode (DAO mode)
Delegation mode)
Address:
Reprinted at will, but please attach the article address :-)