designModeDemo/demo/Structural/Facade/Run.php

41 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace demo\Structural\Facade;
class Run extends \bin\Design
{
/**
* 门面模式的最初目的并不是为了避免让你阅读复杂的 API 文档,这只是一个附带作用。其实它的本意是为了降低耦合性并且遵循 Demeter 定律。
*
* 一个门面旨在通过嵌入许多(但有时只有一个)接口来分离客户端和子系统。当然,也是为了降低复杂度。
*
* 门面不会禁止你访问子系统。
* 你可以(应该)有多个门面对应一个子系统。
* 这就是为什么一个好的门面里没有 new 的原因。如果每个方法都有多种创建,那并不是一个门面,而是一个构建器 [抽象的 | 静态的 | 简单的] 或是一个工厂 [方法] 。
*
* 最好的门面是没有 new 的,并且其构造函数带有接口类型提示的参数。 如果你需要创建新的实例,可以使用工厂作为变量。
*
* @inheritDoc
*/
public function setDesignName() : string
{
return '门面模式Facade';
}
/**
* @inheritDoc
*/
public function setDesignRefUrl() : string
{
return 'https://learnku.com/docs/php-design-patterns/2018/Facade/1502';
}
/**
* @inheritDoc
*/
public function main()
{
// TODO: Implement main() method.
}
}