Php design mode Bridge (Bridge Mode) _ PHP Tutorial

Source: Internet
Author: User
Php design mode Bridge (Bridge mode ). Copy the code as follows :? Php *** bridging mode ** separates the abstract part from its implementation part, and each of them can have independent changes. * abstractclassImplementor {abstractpubl The code is as follows:


/**
* Bridging mode
*
* Separate the abstract part from its implementation part, and use them to have independent changes
*/
Abstract class Implementor
{
Abstract public function operation ();
}
Class ConcreteImplementorA extends Implementor
{
Public function operation ()
{
Echo "ConcreteImplementorA Operation
";
}
}
Class ConcreteImplementorB extends Implementor
{
Public function operation ()
{
Echo "ConcreteImplementorB Operation
";
}
}
Class Program action
{
Protected $ _ implementor = null;
Public function setImplementor ($ implementor)
{
$ This-> _ implementor = $ implementor;
}
Public function operation ()
{
$ This-> _ implementor-> operation ();
}
}
Class RefinedAbstraction extends action
{
}
Class ExampleAbstraction extends action
{
}
//
$ Objr1_action = new refined1_action ();
$ Objr1_action-> setImplementor (new ConcreteImplementorB ());
$ Objr1_action-> operation ();
$ Objr1_action-> setImplementor (new ConcreteImplementorA ());
$ Objr1_action-> operation ();
$ Objedomainaction = new exampledomainaction ();
$ Objesponaction-> setImplementor (new ConcreteImplementorB ());
$ Objesponaction-> operation ();

The http://www.bkjia.com/PHPjc/323618.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323618.htmlTechArticle code is as follows :? Php/*** bridge mode ** separates the abstract part from its implementation part, and each of them can have independent changes */abstract class Implementor {abstract publ...

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.