The appearance mode of PHP design mode

Source: Internet
Author: User
Appearance mode is a structural pattern

Overview: Provides a consistent interface for a set of interfaces in a subsystem that defines a high-level interface that makes this subsystem easier to use

The appearance mode is to let client clients in a simple way to invoke the more complex system to accomplish one thing;

Objective:

1. Provide a simple interface for a complex subsystem

2. Reduce the coupling between the client and the subsystem

Personal examples:

1 buy hand-picked cakes

namespace Haibao\design\web\view\design;

Use Haibao\design\web\common\design\adapter\translator;

Class Facade extends \haibao\design\web\view\base{

protected function PreRender () {

Header ("content-type:text/html; Charset=utf-8 ");

$facade = new \haibao\design\web\common\design\facade\facade ();

$facade->facade1 ();

Echo '

';

$facade->facade2 ();

}

}

/**

* Boss's hand-grasping cookies

*/

namespace Haibao\design\web\common\design\facade;

Class facade{

Public $object 1;

Public $object 2;

Public $object 3;

Public Function __construct () {

$this->object1 = new subsystem1;//cake

$this->object2 = new SubSystem2; Brush will

$this->object3 = new SubSystem3; Add a bowel.

}

Public Function Facade1 () {

$this->object1->getmessage ();

$this->object2->getmessage ();

}

Public Function Facade2 () {

$this->object2->getmessage ();

$this->object3->getmessage ();

}

}

/**

* Sub-class

*/

namespace Haibao\design\web\common\design\facade;

Class subsystem1{

Public Function GetMessage () {

Echo ' subsystem 1 ';

}

}

/**

* Sub-class

*/

namespace Haibao\design\web\common\design\facade;

Class subsystem2{

Public Function GetMessage () {

Echo ' Subsystem 2 ';

}

}

/**

* Sub-class

*/

namespace Haibao\design\web\common\design\facade;

Class subsystem3{

Public Function GetMessage () {

Echo ' Subsystem 3 ';

}

}

  • 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.