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 :-)