摘要: Go手册地址:https://studygolang.com/pkgdoc 一:Go下载安装 1、下载地址:https://golang.org/dl/ https://golang.google.cn/dl/ https://studygolang.com/dl。 2、下载安装包直接下一步安装完成 阅读全文
posted @ 2021-09-14 20:16 wish_yang 阅读(2448) 评论(0) 推荐(0) 编辑
摘要: 迭代器模式: 迭代器模式是提供一个顺序访问一个聚合对象中的各个元素,而不暴露对象内部。类似 for foreach。 <?php class TestIterator implements Iterator{ private $array; private $currentIndex = 0; pu 阅读全文
posted @ 2021-08-26 17:31 wish_yang 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 命令链模式: 通过向一组程序发送处理命令,那个处理结束了则返回,否则就继续执行该组命令的下一条。 <?php /** * 登录接口 */ interface LoginInterface{ public function login($role,$name); } class NormalLogin 阅读全文
posted @ 2021-08-26 17:27 wish_yang 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 观察者模式: 对个对象依赖于一个对象。当一个对象改变时,所有依赖它的对象都会获得通知和改变。发布订阅。 <?php /** * 小说更新接口 */ interface StoryUpdateInterface{ public function update($name); } class Story 阅读全文
posted @ 2021-08-26 15:55 wish_yang 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 策略模式: 一个系统有许多类,根据行为区分作用。我们把他们一个个的封装成类,使得可以替换使用。 <?php /** * 方法接口 */ interface PayInterface{ public function pay(); } class AliPay implements PayInterf 阅读全文
posted @ 2021-08-26 10:58 wish_yang 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 单例模式: 只有一个实例。只可以通过该实例去调用该对象其他方法。单例的最大特点是三私一公。 <?php class DBUtil{ private $conn; private static $instance = null; private function __construct() { try 阅读全文
posted @ 2021-08-25 13:51 wish_yang 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 工厂模式: 分为简单工厂,方法工厂,和抽象工厂。 一:简单工厂 简单工厂的作用是实例化对象,而不需要调用者知道该对象具体对应的子类。 <?php class MysqlLog{ public function log(){ echo '记录Mysql错误'.PHP_EOL; } } class Er 阅读全文
posted @ 2021-08-25 13:36 wish_yang 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 代理模式: 给对象提供一个代理类,由代理对象对外接洽。 <?php interface A { public function boot(); } class B implements A{ public function boot(){ echo '此处是B类'; } } /** * 代理类 */ 阅读全文
posted @ 2021-08-24 15:11 wish_yang 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 适配器模式: 适配器类让原本不兼容的类可以合作共处。类似转换头。 <?php /** * 用户信息接口 */ interface UserInfoInterface{ public function userInfo(); } /** * json 返回的用户类 */ class UserInfoJ 阅读全文
posted @ 2021-08-24 14:37 wish_yang 阅读(39) 评论(0) 推荐(0) 编辑
摘要: 管道模式 又称为Pipleline模式。将复杂的流程分解为多个子系统。将各个子系统按照逻辑次序排列有序的执行下去。类似于工厂的流水线。 <?php class A { public static function handle(){ echo '请求验证'.PHP_EOL; } } class B 阅读全文
posted @ 2021-08-24 14:36 wish_yang 阅读(779) 评论(0) 推荐(0) 编辑