---
title: "16-Observer"
author: "ccfangle"
date: "2012-01-12T21:35:19Z"
tags: []
categories: ["编程语言"]
slug: "16-observer"
draft: false
lastmod: "2012-01-12T21:47:41Z"
id: 1343775
url: "https://ccfangle.iteye.com/blog/1343775"
---

好久之前看过Observer，但是，当时不是很清楚，应该是Java刚刚入门的原因....现在看来啊，是比较优秀、很好的设计模式！

      Like the other forms of callback, this contains a hook point where you can change code. The difference is in the observer’s completely dynamic nature. **It is often used for the specific case of changes based on other object’s change of state,** but is also the basis of event management. Anytime you want to decouple the source of the call from the called code in a completely dynamic way.

[]()[]()[]()Observer模式定义对象间的一对多的依赖关系,当一个对象的状态发生改变时, 所有依赖于它的对象都得到通知并被自动更新。JDK中内置的observer设计模式的实现由java.util.Observable类和 java.util.Observer接口组成。

        具体的实例讲解，参考[这个案例](http://renpeng301.iteye.com/blog/691885) 或者 是教材中的案例都是不错的选择！