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

来源:互联网 发布:pc预测软件 编辑:程序博客网 时间:2024/04/30 09:55

外观模式:

外观模式(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();

  }

...

  

}




0 0