Php design pattern adapter (adapter pattern)

Source: Internet
Author: User
Tags html interpreter
Do you know all the 25 php design patterns? The following code introduces the adapter mode (adapter mode )? In php * Adapter mode...

25 php typesDesign ModeDo you all know? The following code is used to introduceAdapter mode)

 ";} Public function store ($ key, $ value) {echo" OldCache store
";} Public function remove ($ key) {echo" OldCache remove
";} Public function fetch ($ key) {echo" OldCache fetch
";}} Interface Cacheable {public function set ($ key, $ value); public function get ($ key); public function del ($ key );} class OldCacheAdapter implements Cacheable {private $ _ cache = null; public function _ construct () {$ this-> _ cache = new OldCache ();} public function set ($ key, $ value) {return $ this-> _ cache-> store ($ key, $ value);} public function get ($ key) {return $ this-> _ cache-> fetch ($ key);} public function del ($ key) {return $ this-> _ cache-> remove ($ key) ;}$ objCache = new OldCacheAdapter (); $ objCache-> set ("test", 1 ); $ objCache-> get ("test"); $ objCache-> del ("test", 1 );


Other related design patterns:

Http://www.phprm.com/develop/memento.html memorandum mode (Memento mode)
Http://www.phprm.com/develop/observer.html Observer mode (Observer mode)
Template Method pattern (Template Method pattern)
Http://www.phprm.com/develop/command.html command mode)
Http://www.phprm.com/develop/composite.html combination mode (composite mode)
Http://www.phprm.com/develop/flyweight.html enjoy mode (flyweight mode)
Http://www.phprm.com/develop/strategy.html strategy mode)
Http://www.phprm.com/develop/state.html state mode)
Http://www.phprm.com/develop/adapter.html adapter mode (adapter mode)
Http://www.phprm.com/develop/factory.html factory mode (factory mode)
Http://www.phprm.com/develop/prototype.html prototype)
Http://www.phprm.com/develop/facade.html appearance mode (facade mode)
Http://www.phprm.com/develop/singleton.html singleton mode)
Http://www.phprm.com/develop/bridge.html bridge Mode (bridge mode)
Http://www.phprm.com/develop/decorator.html decoration mode (decorator mode)
Http://www.phprm.com/develop/abstract.html abstract factory mode (abstract factory mode)
Http://www.phprm.com/develop/builder.html Builder mode)
Http://www.phprm.com/develop/visitor.html Visitor mode (Visitor mode)
Http://www.phprm.com/develop/interpreter.html Interpreter mode (Interpreter mode)
Http://www.phprm.com/develop/mediator.html Mediator mode)
Http://www.phprm.com/develop/chain.html Responsibility Chain model (Chain Of Responsibility model)
Http://www.phprm.com/develop/proxy.html Proxy mode)
Http://www.phprm.com/develop/interator.html iterator mode)
Http://www.phprm.com/develop/dao.html Data Access Object mode (DAO mode)
Http://www.phprm.com/develop/delegation.html delegate mode (Delegation mode)


Address: http://www.phprm.com/develop/adapter.html

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.