Php design mode Delegation (Delegation mode)

Source: Internet
Author: User
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 :-)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.