1 / 10

Observer pattern

Observer pattern. 권문범. Observer pattern. 객체의 상태 벼화를 관찰 , 상태 변화가 있을 때마다 메서드 등을 통해 객체가 직접 목록의 옵저버들에세 통지하도록 하는 디자인 패턴 주로 ‘ 분산 이벤트 핸들링 시스템 ’ 에 사용 발행 / 구독 모델로도 알려짐. Why do we need a Observer?. 데이터 소스. 데이터의 변화가 있을 때마다 각 뷰 객체에 바뀐 내용을 전달 문제점 : 뷰 객체의 개수는 무궁무진하고 각 종류가 다를 수 있다.

gay-everett
Télécharger la présentation

Observer pattern

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Observer pattern 권문범

  2. Observer pattern • 객체의 상태 벼화를 관찰, 상태 변화가 있을 때마다 메서드 등을 통해 객체가 직접 목록의 옵저버들에세 통지하도록 하는 디자인 패턴 • 주로 ‘분산 이벤트 핸들링 시스템’에 사용 • 발행/구독 모델로도 알려짐.

  3. Why do we needa Observer? 데이터 소스 데이터의 변화가 있을 때마다 각 뷰 객체에 바뀐 내용을 전달 문제점 : 뷰 객체의 개수는 무궁무진하고 각 종류가 다를 수 있다.

  4. Why do we needa Observer? Object 데이터 소스 개발자를 대신해 각 뷰 객체들을 관리하고 데이터의 변화를 알려줄 수 있는 객체가 있다면 프로그래밍이 훨씬 편리해 질것이다.

  5. Observer pattern in UML

  6. Observerpattern in java • Observable(클래스) • addObserver(Observer o); • setChanged(); • notifyObservers(); • notifyObservers(Object arg);

  7. Observer pattern in java • Observer(인터페이스) • update(Observable o, Object arg);

  8. Observer pattern in iOS • Notification center • 모델의 데이터가 변화가 생겼을 때, 노티피케이션을 발생 • 노티피케이션과 같이 전송할 객체를 ‘userInfo’로 전송

  9. Observer pattern in iOS • Observer • 노티피케이션 센터에 옵저버를 등록 • ‘addObserver:selector: name: object:’ • Selector는 update 메소드

  10. 참고 문헌 • Head First Design Patterns, 에릭 프리먼 외 3명, 서환수 역, 한빛미디어 • GoF의 디자인 패턴, 에릭 감마 외 3명, 김정아 역, 피어슨 에듀케이션 • 위키백과 :http://ko.wikipedia.org/wiki/옵서버_패턴

More Related