<small id='1XoNe'></small> <noframes id='GtcEb'>

  • <tfoot id='mQ6LN'></tfoot>

      <legend id='esQ69'><style id='xrT7Zj'><dir id='k1oyR6l54r'><q id='fzZ3'></q></dir></style></legend>
      <i id='CYALBfGlU8'><tr id='uWiEpdK'><dt id='SRfbJO'><q id='iQbv3H9sDN'><span id='bSWe'><b id='2BZuyC'><form id='qiIVbN'><ins id='omda9zUe3l'></ins><ul id='R8CU4fg'></ul><sub id='PcVxfG5'></sub></form><legend id='Nxh4T5p'></legend><bdo id='IUZpuM'><pre id='jdT3t'><center id='aSKRG'></center></pre></bdo></b><th id='2fEqRkam4V'></th></span></q></dt></tr></i><div id='2NPW'><tfoot id='scGKHSDplJ'></tfoot><dl id='tKLnBQ'><fieldset id='zMGnuD'></fieldset></dl></div>

          <bdo id='O5Rq7'></bdo><ul id='CjJlY'></ul>

          1. <li id='GmlNb9Bka'></li>
            登陆

            规划形式专题08-外观形式

            admin 2019-11-01 248人围观 ,发现0个评论

            外观形式(下一篇:原型形式)

            什么是外观形式

            外观形式(Facade Pattern)门面形式,躲藏体系的复杂性,并向客户端供给了一个客户端能够拜访体系的接口。这种类型的规划形式归于结构型形式,它向现有的体系增加一个接口,来躲藏体系的复杂性。

            这种形式涉及到一个单一的类,该类供给了客户端恳求的简化办法和对现有体系类办法的托付调用。

            外观形式比如

            用户注册完之后,需求调用阿里短信接口、邮件接口、微信推送接口。

            public interface EamilSmsService {
            public void sendSms();
            }
            public class EamilSmsServiceImpl implements EamilSmsService{
            public void sendSms() {
            System.out.prin规划形式专题08-外观形式tln("发送邮件音讯");
            }
            }


            //微信音讯推送
            public interface WeiXinS规划形式专题08-外观形式msService {
            public void sendSms();
            }
            public class EamilSmsServiceImpl implements EamilSmsService{

            @Override
            public void sendSms() {
            System.out.println("发送邮件音讯");
            }

            }

            //阿里短信音讯
            public interface AliSmsService {
            public void sendSms();
            }
            public 规划形式专题08-外观形式class AliSmsServiceImpl implements AliSmsService {

            @Override
            public void sendSms() {
            System.out.println("支付宝发送音讯...");
            }

            }

            门面类

            public class Computer {
            AliSmsService aliSmsService;
            EamilSmsService eamilSmsService;
            WeiXinSmsService weiXinSmsService;

            public Computer() {
            aliSmsServi规划形式专题08-外观形式ce = new AliSmsServiceImpl();
            eamilSmsService = new EamilSmsServiceImpl();
            weiXinSmsService = new WeiXinSmsServiceImpl();
            }

            public void sendMsg() {
            aliSmsService.sendSms();
            eamilSmsService.sendSms();
            weiXinSmsService.sendSms();

            }

            }

            public class Client {

            public static void main(String[] args) {
            // AliSmsService aliSmsService= new AliSmsServiceImpl();
            // EamilSmsService eamilS规划形式专题08-外观形式msService= new EamilSmsServiceImpl();
            // WeiXinSmsService weiXinSmsService= new WeiXinSmsServiceImpl();
            // aliSmsService.sendSms();
            // eamilSmsService.sendSms();
            // we王明iXinSmsService.sendSms();
            new Computer().sendMsg();
            }

            }

            请关注微信公众号
            微信二维码
            不容错过
            Powered By Z-BlogPHP