您的位置:首页 > 其它

读书笔记-外观模式又叫门面模式

2017-05-05 17:59 246 查看
外观模式:

外观模式(Facade),为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。



四个子系统的类

class SubSystemOne{

  public void MethodOne(){

      System.err.println("子系统方法一");

   }

}

class SubSystemTwo{

   public void MethodTwo(){

       System.err.println("子系统方法二");

    }

}

class SubSystemThree{

  public void MethodThree(){

     System.err.println("子系统方法三");

   }

}

class SubSystemFour{

  public void MethodFour(){

     System.err.println("子系统方法四");

   }

}

外观类

class Facede

{

   SubSystemOne one;

   SubSystemTwo two;

   SubSystemThree three;

   SubSystemFour four;

   public Facede(){

     one = new SubSystemOne();

     two = new SubSystemTwo();

    three = new SubSystemThree();

    four = new SubSystemFour();

  }

...

  

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: