SlideShare una empresa de Scribd logo
1 de 13
Design Patterns
Observer
Written by: Andrey Stakhievich,
Automation Department,
Coherent Solutions
Definition
Observer defines:
a one-to-many dependency between objects
so that when one object changes state,
all its dependents are notified and updated
automatically.
Description
• The observer design pattern enables a subscriber to
register with and receive notifications from a provider. It
is suitable for any scenario that requires push-based
notification.
• The pattern defines a provider (also known as a subject
or an observable) and zero, one, or more observers.
• Observers register with the provider, and whenever a
predefined condition, event, or state change occurs, the
provider automatically notifies all observers by calling
one of their methods.
• In this method call, the provider can also provide current
state information to observers.
Real Life Metaphor
Some auctions demonstrate this pattern. Each
bidder possesses a numbered paddle that is
used to indicate a bid.
The auctioneer starts the bidding, and
"observes" when a paddle is raised to accept the
bid.
The acceptance of the bid changes the bid price
which is broadcast to all of the bidders in the
form of a new bid.
Check List
1. Differentiate between the core (or independent) functionality and
the optional (or dependent) functionality.
2. Model the independent functionality with a "subject" abstraction.
3. Model the dependent functionality with an "observer" hierarchy.
4. The Subject is coupled only to the Observer base class.
5. The client configures the number and type of Observers.
6. Observers register themselves with the Subject.
7. The Subject broadcasts events to all registered Observers.
8. The Subject may "push" information at the Observers, or, the
Observers may "pull" the information they need from the Subject.
UML Diagram
Entities
• Subject (IObservable)
– knows its observers. Any number of Observer objects may observe a subject
– provides an interface for attaching and detaching Observer objects.
• Concrete Subject
– stores state of interest to Concrete Observer
– sends a notification to its observers when its state changes
• Observer (IObserver)
– defines an updating interface for objects that should be notified of changes in
a subject.
• Concrete Observer
– maintains a reference to a Concrete Subject object
– stores state that should stay consistent with the subject's
– implements the Observer updating interface to keep its state consistent with
the subject's
.Net Implementation
In the .NET Framework, the observer design
pattern is applied by implementing the generic
System.IObservable<T> and
System.IObserver<T> interfaces.
The generic type parameter represents the type
that provides notification information.
IObserver
public interface IObserver<in T>
{
//Notifies the observer that the provider has finished sending push-based
//notifications.
void OnCompleted();
//Notifies the observer that the provider has experienced an error
//condition. An object that provides additional information about the error.
void OnError(Exception error);
//Provides the observer with new data. The current notification information.
void OnNext(T value);
}
IObservable
public interface IObservable<out T>
{
//Summary:
//Notifies the provider that an observer is to receive notifications.
//
//Parameters:
//observer:
//The object that is to receive notifications.
//
//Returns:
//A reference to an interface that allows observers to stop receiving notifications
//before the provider has finished sending them.
IDisposable Subscribe (IObserver <T>observer);
}
Final Comparison
Chain of Responsibility, Command, Mediator, and
Observer, address how you can decouple senders and
receivers, but with different trade-offs.
Chain of Responsibility passes a sender request along a
chain of potential receivers.
Command normally specifies a sender-receiver
connection with a subclass.
Mediator has senders and receivers reference each other
indirectly.
Observer defines a very decoupled interface that allows
for multiple receivers to be configured at run-time.
The end…
But..
This presentation could not be
completed without…
The sources of information:
1. http://www.dofactory.com/Patterns/PatternObserver.aspx
2. http://www.vincehuston.org/dp/observer.html
3. Design Patterns: Elements of Reusable Object-oriented
Software, by Erich Gamma, Richard Helm, Ralph Johnson, John
Vlissides, 1995 – “Gang of Four”
4. Special Thanks to Denis Sajin for providing the cute cats

Más contenido relacionado

Destacado

Observer & singleton pattern
Observer  & singleton patternObserver  & singleton pattern
Observer & singleton pattern
babak danyal
 
Design patterns 4 - observer pattern
Design patterns   4 - observer patternDesign patterns   4 - observer pattern
Design patterns 4 - observer pattern
pixelblend
 
Observer Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 AugObserver Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 Aug
melbournepatterns
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
Sara Torkey
 
Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...
Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...
Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...
Crishantha Nanayakkara
 

Destacado (20)

Observer & singleton pattern
Observer  & singleton patternObserver  & singleton pattern
Observer & singleton pattern
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Design patterns 4 - observer pattern
Design patterns   4 - observer patternDesign patterns   4 - observer pattern
Design patterns 4 - observer pattern
 
Design patterns: observer pattern
Design patterns: observer patternDesign patterns: observer pattern
Design patterns: observer pattern
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Observer Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 AugObserver Pattern Khali Young 2006 Aug
Observer Pattern Khali Young 2006 Aug
 
Factory Pattern
Factory PatternFactory Pattern
Factory Pattern
 
Reflective portfolio
Reflective portfolioReflective portfolio
Reflective portfolio
 
Design patterns - Observer Pattern
Design patterns - Observer PatternDesign patterns - Observer Pattern
Design patterns - Observer Pattern
 
Design Pattern - Observer Pattern
Design Pattern - Observer PatternDesign Pattern - Observer Pattern
Design Pattern - Observer Pattern
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
Observer Pattern
Observer PatternObserver Pattern
Observer Pattern
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
Design pattern - Software Engineering
Design pattern - Software EngineeringDesign pattern - Software Engineering
Design pattern - Software Engineering
 
Observer and Decorator Pattern
Observer and Decorator PatternObserver and Decorator Pattern
Observer and Decorator Pattern
 
Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...
Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...
Colombo Architecture Meetup - Enterprise Architectural Challenges in Large En...
 
ICTA Technology Meetup 06 - Enterprise Application Design Patterns
ICTA Technology Meetup 06 - Enterprise Application Design PatternsICTA Technology Meetup 06 - Enterprise Application Design Patterns
ICTA Technology Meetup 06 - Enterprise Application Design Patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

Similar a Design patterns

Similar a Design patterns (20)

Observer pattern
Observer patternObserver pattern
Observer pattern
 
pattern v
pattern vpattern v
pattern v
 
Reactive programming with RxAndroid
Reactive programming with RxAndroidReactive programming with RxAndroid
Reactive programming with RxAndroid
 
Rxandroid
RxandroidRxandroid
Rxandroid
 
RxAndroid
RxAndroidRxAndroid
RxAndroid
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
 
Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
 
Strange Async Code - ReaxtiveX
Strange Async Code - ReaxtiveXStrange Async Code - ReaxtiveX
Strange Async Code - ReaxtiveX
 
A4WSN
A4WSNA4WSN
A4WSN
 
Observer Design Pattern to Observe Something
Observer Design Pattern to Observe SomethingObserver Design Pattern to Observe Something
Observer Design Pattern to Observe Something
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
 
Tarefapatterns
TarefapatternsTarefapatterns
Tarefapatterns
 
Android reactive programming using agera
Android reactive programming using ageraAndroid reactive programming using agera
Android reactive programming using agera
 
LWM2M Introduction - Edinburgh 2016 Workshop with ARM
LWM2M Introduction - Edinburgh 2016 Workshop with ARMLWM2M Introduction - Edinburgh 2016 Workshop with ARM
LWM2M Introduction - Edinburgh 2016 Workshop with ARM
 
Listeners and filters in servlet
Listeners and filters in servletListeners and filters in servlet
Listeners and filters in servlet
 
IoT in salsa Serverless
IoT in salsa ServerlessIoT in salsa Serverless
IoT in salsa Serverless
 
Observer-MVVM-RxJava
Observer-MVVM-RxJavaObserver-MVVM-RxJava
Observer-MVVM-RxJava
 

Más de ISsoft

Sql инъекции в тестировании
Sql инъекции в тестированииSql инъекции в тестировании
Sql инъекции в тестировании
ISsoft
 
введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...
введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...
введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...
ISsoft
 
Testing, qa, qc. what the difference
Testing, qa, qc. what the differenceTesting, qa, qc. what the difference
Testing, qa, qc. what the difference
ISsoft
 
Ranorex presentation
Ranorex presentationRanorex presentation
Ranorex presentation
ISsoft
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проекте
ISsoft
 
Тестирование требований
Тестирование требованийТестирование требований
Тестирование требований
ISsoft
 
Тестирование требований
Тестирование требованийТестирование требований
Тестирование требований
ISsoft
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
ISsoft
 
Отдел юзабилити
Отдел юзабилитиОтдел юзабилити
Отдел юзабилити
ISsoft
 
ToDoList
ToDoListToDoList
ToDoList
ISsoft
 
Prototype presentation
Prototype presentationPrototype presentation
Prototype presentation
ISsoft
 
решение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте baрешение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте ba
ISsoft
 
решение одной из ключевых проблем компетенции Ba специалистов
решение одной из ключевых проблем компетенции Ba специалистоврешение одной из ключевых проблем компетенции Ba специалистов
решение одной из ключевых проблем компетенции Ba специалистов
ISsoft
 
Development of automated tests for ext js based web sites
Development of automated tests for ext js based web sitesDevelopment of automated tests for ext js based web sites
Development of automated tests for ext js based web sites
ISsoft
 
Bdd or dsl как способ построения коммуникации на проекте
Bdd or dsl как способ построения коммуникации на проектеBdd or dsl как способ построения коммуникации на проекте
Bdd or dsl как способ построения коммуникации на проекте
ISsoft
 
инфотекс автоматизация тестирования
инфотекс   автоматизация тестированияинфотекс   автоматизация тестирования
инфотекс автоматизация тестирования
ISsoft
 

Más de ISsoft (20)

Sql инъекции в тестировании
Sql инъекции в тестированииSql инъекции в тестировании
Sql инъекции в тестировании
 
введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...
введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...
введение в практическую разработку по в Is soft 4-1 and 4-2 clients and commu...
 
Testing of mobile apps
Testing of mobile appsTesting of mobile apps
Testing of mobile apps
 
Testing, qa, qc. what the difference
Testing, qa, qc. what the differenceTesting, qa, qc. what the difference
Testing, qa, qc. what the difference
 
Ranorex presentation
Ranorex presentationRanorex presentation
Ranorex presentation
 
Bugs
BugsBugs
Bugs
 
Bdd j behave or cucumber jvm plus appium for efficient cross platform mobile ...
Bdd j behave or cucumber jvm plus appium for efficient cross platform mobile ...Bdd j behave or cucumber jvm plus appium for efficient cross platform mobile ...
Bdd j behave or cucumber jvm plus appium for efficient cross platform mobile ...
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проекте
 
Тестирование требований
Тестирование требованийТестирование требований
Тестирование требований
 
Тестирование требований
Тестирование требованийТестирование требований
Тестирование требований
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
Отдел юзабилити
Отдел юзабилитиОтдел юзабилити
Отдел юзабилити
 
ToDoList
ToDoListToDoList
ToDoList
 
ISTQB
ISTQBISTQB
ISTQB
 
Prototype presentation
Prototype presentationPrototype presentation
Prototype presentation
 
решение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте baрешение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте ba
 
решение одной из ключевых проблем компетенции Ba специалистов
решение одной из ключевых проблем компетенции Ba специалистоврешение одной из ключевых проблем компетенции Ba специалистов
решение одной из ключевых проблем компетенции Ba специалистов
 
Development of automated tests for ext js based web sites
Development of automated tests for ext js based web sitesDevelopment of automated tests for ext js based web sites
Development of automated tests for ext js based web sites
 
Bdd or dsl как способ построения коммуникации на проекте
Bdd or dsl как способ построения коммуникации на проектеBdd or dsl как способ построения коммуникации на проекте
Bdd or dsl как способ построения коммуникации на проекте
 
инфотекс автоматизация тестирования
инфотекс   автоматизация тестированияинфотекс   автоматизация тестирования
инфотекс автоматизация тестирования
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

Design patterns

  • 1. Design Patterns Observer Written by: Andrey Stakhievich, Automation Department, Coherent Solutions
  • 2. Definition Observer defines: a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
  • 3. Description • The observer design pattern enables a subscriber to register with and receive notifications from a provider. It is suitable for any scenario that requires push-based notification. • The pattern defines a provider (also known as a subject or an observable) and zero, one, or more observers. • Observers register with the provider, and whenever a predefined condition, event, or state change occurs, the provider automatically notifies all observers by calling one of their methods. • In this method call, the provider can also provide current state information to observers.
  • 4. Real Life Metaphor Some auctions demonstrate this pattern. Each bidder possesses a numbered paddle that is used to indicate a bid. The auctioneer starts the bidding, and "observes" when a paddle is raised to accept the bid. The acceptance of the bid changes the bid price which is broadcast to all of the bidders in the form of a new bid.
  • 5. Check List 1. Differentiate between the core (or independent) functionality and the optional (or dependent) functionality. 2. Model the independent functionality with a "subject" abstraction. 3. Model the dependent functionality with an "observer" hierarchy. 4. The Subject is coupled only to the Observer base class. 5. The client configures the number and type of Observers. 6. Observers register themselves with the Subject. 7. The Subject broadcasts events to all registered Observers. 8. The Subject may "push" information at the Observers, or, the Observers may "pull" the information they need from the Subject.
  • 7. Entities • Subject (IObservable) – knows its observers. Any number of Observer objects may observe a subject – provides an interface for attaching and detaching Observer objects. • Concrete Subject – stores state of interest to Concrete Observer – sends a notification to its observers when its state changes • Observer (IObserver) – defines an updating interface for objects that should be notified of changes in a subject. • Concrete Observer – maintains a reference to a Concrete Subject object – stores state that should stay consistent with the subject's – implements the Observer updating interface to keep its state consistent with the subject's
  • 8. .Net Implementation In the .NET Framework, the observer design pattern is applied by implementing the generic System.IObservable<T> and System.IObserver<T> interfaces. The generic type parameter represents the type that provides notification information.
  • 9. IObserver public interface IObserver<in T> { //Notifies the observer that the provider has finished sending push-based //notifications. void OnCompleted(); //Notifies the observer that the provider has experienced an error //condition. An object that provides additional information about the error. void OnError(Exception error); //Provides the observer with new data. The current notification information. void OnNext(T value); }
  • 10. IObservable public interface IObservable<out T> { //Summary: //Notifies the provider that an observer is to receive notifications. // //Parameters: //observer: //The object that is to receive notifications. // //Returns: //A reference to an interface that allows observers to stop receiving notifications //before the provider has finished sending them. IDisposable Subscribe (IObserver <T>observer); }
  • 11. Final Comparison Chain of Responsibility, Command, Mediator, and Observer, address how you can decouple senders and receivers, but with different trade-offs. Chain of Responsibility passes a sender request along a chain of potential receivers. Command normally specifies a sender-receiver connection with a subclass. Mediator has senders and receivers reference each other indirectly. Observer defines a very decoupled interface that allows for multiple receivers to be configured at run-time.
  • 13. But.. This presentation could not be completed without… The sources of information: 1. http://www.dofactory.com/Patterns/PatternObserver.aspx 2. http://www.vincehuston.org/dp/observer.html 3. Design Patterns: Elements of Reusable Object-oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, 1995 – “Gang of Four” 4. Special Thanks to Denis Sajin for providing the cute cats