14-Bridge

    思考了好一阵,总是没有一个合适的答案,感觉没有办法继续往下写了....

    先展示一下Bridge设计模式的目的就是:将抽象与其实现解耦,使它们可以独立的适应变化,这是在Gof中的描述(很是通用,但是没有感觉....)

     老实说,教材中的例子比较抽象啊,不是很容易理解,但是讲解还算可以,毕竟是外文啊,参考了一些博客内容,感觉这个讲解比较集中,好理解。

     桥梁模式的用意是将问题的抽象和实现分离开来实现,通过用聚合代替继承来解决子类爆炸性增长的问题。
比如我们有一个画图程序 有2个图形(Circle Rectangle )和2种画图方法(Drawing1 Drawing2)
图形可能会使用Drawing1来画图 也可能使用Drawing2来画图
在这个画图程序中有两个可变因素 一个是图形的种类 有可能会增加新的图形 另一个是画图方法 可能会有Drawing3出现
当系统有两个可变因素时 我就应该考虑到桥梁模式,至少它应该在你的脑子里闪过

在面向对象设计中有两条重要原则
1.找出变化并封装之
2.优先使用聚合而不是继承


这两条将在桥梁模式中得到完美体现


具体的例子看上面这个链接、教材、和这个链接 就够了!实际的应用中用到了,再做补充!仔细想来,这个算作connecting different types 的模式是很准确的,它就像是两个Strategy模式拼凑而成,从一端变化转化为两端都在变化,相同点是遵循了面向接口编程+接口的开闭原则!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
[root@his ~]# kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=v1.25.0 --apiserver-advertise-address=192.168.8.109 [init] Using Kubernetes version: v1.25.0 [preflight] Running pre-flight checks [WARNING Hostname]: hostname "his" could not be reached [WARNING Hostname]: hostname "his": lookup his on 192.168.8.254:53: no such host error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR CRI]: container runtime is not running: output: E0714 18:14:51.757340 11481 remote_runtime.go:616] "Status from runtime service failed" err="rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/containerd/containerd.sock: connect: no such file or directory\"" time="2023-07-14T18:14:51+08:00" level=fatal msg="getting status of runtime: rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/containerd/containerd.sock: connect: no such file or directory\"" , error: exit status 1 [ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1 [ERROR KubeletVersion]: the kubelet version is higher than the control plane version. This is not a supported version skew and may lead to a malfunctional cluster. Kubelet version: "1.27.3" Control plane version: "1.25.0" [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` To see the stack trace of this error execute with --v=5 or higher
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值