概念提供了一个统一的接口来访问多个子系统的多个不同接口,它为子系统中的一组接口提供了一个统一的高层接口。使用子系统更容易使用。本质:化部分为整体;引入一个中介类,将各种分散的功能组合成一个整体,对外只暴露一个统一的接口。例:商人水果摊的日子是这样的:1.打开水果摊的门2.取出水果3.把水果放到货架上4.把水果从货架上拿下来5.把水果放回去6.关门open();//1。开门$fruits=newFruits();$fruits->take();//2。取出水果$shelves=newShelves();$shelves->putOn();//3。把水果放在货架上//关闭状态$shelves->putDown();//4。摘下水果$fruits->put();//5。把水果放回去$door->close();//6。关门/***门面设计模式*/classFruitsLife{protected$protected$fruits;受保护的$货架;公共函数__construct(){$this->door=newDoor();$this->fruits=newFruits();$this->shelves=newShelves();//业务状态publicfunctionopen(){$this->door->open();//1。打开门$this->fruits->take();//2。取出水果$this->shelves->putOn();//3。货架上的水果}//关闭状态publicfunctionclose(){$this->shelves->putDown();//4。水果下架$this->fruits->put();//5。把水果放回去$this->door->close();//6。关门}}/***在门面设计模式下,水果摊的日常是这样的*/$fruitsLife=newFruitsLife();//业务状态$fruitsLife->opne();//关闭状态$fruitsLife->close();
