How do you implement Observer Design Pattern in .NET?

User gives importance to the way your application collects data and displays data on need. There are situations when same data has to be presented in multiple representations at the same time.

When the data changes all these representations should reflect the change. This situation is common in stock market where you represent the stock fluctuations using a graph showing fluctuation of a stock’s rate per day, per week and per month. In addition, you will also have its current rate getting updated in a table.

How do you present your stock data in these many views? This is accomplished using observer pattern which takes care of presenting data in several different forms at the same time. You can implement observer pattern in .NET by defining interfaces similar to the ones shown below:

public interface Observer {
void sendNotification(string msg);
public interface Subject {
void registerObserver(Observer sampleObs);

Data which you are going to present to User is termed as Subject and each of the different representations of data will be referred as Observer. Each Observer has to be registered using registerObserver method of the Subject and when there is a change in data, all observers registered for the Subject will be notified using sendNotification method of Observer. You can inherit these two interfaces and present your data in different forms.

| How do you implement Observer Design Pattern in .NET? | How do you pass data between different Tiers in .NET Architecture? | How is Classic ADO different from ADO.NET? | How is Dataadapter useful in ADO.NET? | How is Datareader different from Dataset in ADO.NET? | How is .NET Application Development different from Traditional Development? | How is HashTable different from ArrayList in .NET? | How is Inheritance achieved in C#? | How is new keyword different from override keyword during inheritance in .NET? | How is String class different from StringBuilder class in .NET? | Illustrate ADO.NET Architecture | Illustrate the importance of Server.Transfer and Response.Redirect in .NET? | Mention the different objects available in Dataset of ADO.NET | Mention the usage of Connection Object in ADO.NET | What are the commonly used methods of Dataadapter in ADO.NET? | What are the different Behavioral Design Patterns that can be used in .NET Architecture? | What are the different Creational Design Patterns that can be used in .NET Architecture? | What are the different Structural Design Patterns that can be used in .NET Architecture? | What are the methods provided by Command Objects in ADO.NET? | What is Internal Access Modifier in C#? |

“Amazon and the Amazon logo are trademarks of, Inc. or its affiliates.”

| Privacy Policy for | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.