008、外观模式

一、UML图

二、实例

1、SubSystemN

package com.designPattern.facade;

/**
 * Created by ZhangJintao on 2020/3/12.
 */
public class CollectionData {
    public void collectionData(){
        System.out.println("我是数据采集层,负责采集数据。");
    }
}
package com.designPattern.facade;

/**
 * Created by ZhangJintao on 2020/3/12.
 */
public class CalculateData {
    public void calculateData(){
        System.out.println("我是数据处理层,负责处理数据!");
    }
}
package com.designPattern.facade;

/**
 * Created by ZhangJintao on 2020/3/12.
 */
public class DataInDb {
    public void dataInDb(){
        System.out.println("我是数据入关系数据库层!");
    }
}
package com.designPattern.facade;

/**
 * Created by ZhangJintao on 2020/3/12.
 */
public class DataView {
    public void dataView(){
        System.out.println("我是数据展示层,负责将数据展示出来!");
    }
}

2、Facade

package com.designPattern.facade;

/**
 * Created by ZhangJintao on 2020/3/12.
 */
public class DataDealFacade {
    private CalculateData calculateData;
    private CollectionData collectionData;
    private DataInDb dataInDb;
    private DataView dataView;


    public DataDealFacade() {
        this.calculateData = new CalculateData();
        this.collectionData = new CollectionData();
        this.dataInDb = new DataInDb();
        this.dataView = new DataView();
    }


    public void dealData(){
        calculateData.calculateData();
        collectionData.collectionData();
        dataInDb.dataInDb();
        dataView.dataView();
    }
}

3、Client 

package com.designPattern.facade;

/**
 * Created by ZhangJintao on 2020/3/12.
 */
public class main {
    public static void main(String[] args) {
        DataDealFacade dataDealFacade = new DataDealFacade();
        dataDealFacade.dealData();
    }
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值