---
title: "设计模式快速参考－外观模式"
author: "gurudk"
date: "2008-12-06T07:03:44Z"
tags: ["设计模式"]
slug: "untitled"
draft: false
lastmod: "2008-12-06T07:03:44Z"
id: 288032
url: "https://gurudk.iteye.com/blog/288032"
---

为一组类提供简单的外部接口,使外部调用者不需要和所有内部干系人打交道,就能让调用者满意。

 

```
class CallCenter{
   public void solve(Customer customer){
      //接受客户提出的问题
      operator.acceptProblem(customer.getProblem());
      boolean canSolved = operator.solve();
      if (!canSolved) {
         //如果不能解决,则请求其它人帮助。
         operator.askHelp();
      }
   }
}

class Customer{
   public void call(CallCenter callCenter){
      callCenter.solve(this);
   }
}

class Operator{
}
```

 

 

**Client:**

 

```
CallCenter callCenter = new CallCenter();
Custom aCustomer = new Customer();
aCustomer.call(callCenter);
```

      这里对客户来讲,与他接触的只有一个接口,就是接线员,最后的结果是解决他的问题。接线员可以直接解决,如果他不能解决,它可以选择请求其它人的帮助去解决这个问题。客户是不关心接线员在内部做了什么。