---
title: "【读书笔记】HeadFirst设计模式——装饰者和适配器的区别"
author: "nathan09"
date: "2012-03-25T01:25:00Z"
tags: []
slug: "headfirst"
draft: false
lastmod: "2012-12-06T11:27:36Z"
id: 1742529
url: "https://nathan09.iteye.com/blog/1742529"
---

装饰者和被装饰者实现了同一个接口，给被装饰者增加功能。即装饰者和被装饰者一定是在同一继承体系的。

适配器和被适配者不实现同一接口，适配器将被适配者转换成客户适用的接口暴露给客户使用。

装饰者：

![](http://hi.csdn.net/attachment/201203/24/0_1332610069HqD7.gif)

适配器：

![](http://hi.csdn.net/attachment/201203/24/0_1332610089H15v.gif)