来说说(Facade)外观模式
来源:互联网 发布:golang redis expire 编辑:程序博客网 时间:2024/06/13 16:55
外观模式的实用性?
1.为一个复杂子系统提供一个简单接口。
2.提高子系统的独立性。
3.在层次化结构中,可以使用Facade模式定义系统中每一层的入口。代码实现
using System;using UnityEngine;public class AdpaterTestDemo{public void testBirdgeMain(){Mortgage mo = new Mortgage ();Customers cus = new Customers ();if(mo.IsEligible(cus)){Debug.Log ("贷款没问题");}}}public class Mortgage{Bank mBank = new Bank();Credit mCredit = new Credit();Loan mLoan = new Loan ();public bool IsEligible(Customers customer){bool isEligible = true;if(!mBank.HasSufficientSavings(customer)){isEligible = false;}if(!mCredit.HasSufficientSavings(customer)){isEligible = false;}if(!mLoan.HasSufficientSavings(customer)){isEligible = false;}return isEligible;}}/// <summary>/// 外观模式/// </summary>public class Customers{private string name;public string Name{set{ name = value; }get{ return name;}}}public class Bank{public bool HasSufficientSavings(Customers c){Debug.Log ("Bank : HasSufficientSavings");return true;}}public class Credit{public bool HasSufficientSavings(Customers c){Debug.Log ("Credit : HasSufficientSavings");return true;}}public class Loan{public bool HasSufficientSavings(Customers c){Debug.Log ("Credit : HasSufficientSavings");return true;}}
facade几个要点
从客户程序的角度来看,Facade模式不仅简化了整个组件系统的接口,同时对于组件内部与外部客户程序来说,从某种程度上也达到了一种“解耦”的效果----内部子系统的任何变化不会影响到Facade接口的变化。
Facade设计模式更注重从架构的层次去看整个系统,而不是单个类的层次。Facdae很多时候更是一种架构
设计模式。
注意区分Facade模式、Adapter模式、Bridge模式与Decorator模式。Facade模式注重简化接口,Adapter模式注重转换接口,Bridge模式注重分离接口(抽象)与其实现,Decorator模式注重稳定接口的前提下为对象扩展功能。
Facade设计模式更注重从架构的层次去看整个系统,而不是单个类的层次。Facdae很多时候更是一种架构
设计模式。
注意区分Facade模式、Adapter模式、Bridge模式与Decorator模式。Facade模式注重简化接口,Adapter模式注重转换接口,Bridge模式注重分离接口(抽象)与其实现,Decorator模式注重稳定接口的前提下为对象扩展功能。
阅读全文
0 0
- 来说说(Facade)外观模式
- Facade模式(外观模式)
- 外观模式(Facade)
- 外观模式(Facade Pattern)
- 外观(Facade)模式
- 外观模式(Facade Pattern)
- Facade(外观)模式
- Facade外观模式
- facade(外观模式)
- Facade 外观模式
- 外观模式(Facade)
- Facade外观模式
- Facade外观模式
- 外观模式Facade
- 外观模式(Facade)
- Facade(外观)模式
- Facade外观模式
- 外观模式(Facade)
- spring中使用字符串注入collection,如set/array
- Error: Spawn SVN ENOENT
- 窗口的布局
- 使用WebView加载本地网页
- MQTT_笔记
- 来说说(Facade)外观模式
- 关于怎么在mysql中执行*.sql文件
- 整理ING
- SonarQube的安装
- fabric下载文件
- Redis:ServiceStack.Redis之IRedisClient
- Cocoa pods的安装和使用详解
- 毕业季的你准备好面试了吗(上)
- ioctl返回失败,驱动中ioctl没调问题解决