160 likes | 289 Vues
Observer Pattern Mediator Pattern. 인공지능 연구실 변윤관. Observer Pattern VS Mediator Pattern. The Observer pattern: Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. The Mediator pattern:
E N D
Observer PatternMediator Pattern 인공지능 연구실 변윤관
Observer Pattern VS Mediator Pattern • The Observer pattern: • Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. • The Mediator pattern: • Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
Subject Implement 옵저버리스트에 있는 모든 옵저버에게 update() 메소드 콜
Observer Test 서브젝트를 관찰할 옵저버 등록 서브젝트의 내용이 바뀌어서 옵저버에게 notify
경보발령시스템 receiver1 경보메시지 경보메시지 경보메시지 receiver2 alerter gateway 경보메시지 receiverN