Observer pattern - Example in C #

The pattern observer defines a ratio of one to many, in which a single object, we will call the observable be notified each time you change from state to many objects, we say observers.

The operation of this design pattern can be compared with that of a subscription to a magazine, and that observers are signed and each time the magazine, (observable), is updated, it is sent to the Observers subscribers.

The definition of the observer pattern is the following: define a dependency between objects from one to many, so that when an object changes its state, all their dependents are notified and updated automatically.

To demonstrate the use of this pattern, an example where we have a main form that has 2 buttons, one to open multiple instances of observers, which in our case are forms that display a list from a data source , An XML file more specifically, and another button to open our simulator edition, which is simply a form that will allow us to edit the data source and allow us to see that every time you alter the data our observers will be notified and updated automatically .

It is important to note that for proper implementation of the standard interfaces are used to define the role of a class as Note or Observer , which we forget, for example of how each class behaves when it is notified of a change of state.

Let’s look at the diagram of classes and then the link to download our mini-application that implements the observer pattern in C #.

Sample Observer Pattern in C #

Also, you may be interested:




Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • co.mments
  • De.lirio.us
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
Strategy pattern: Definition and example in JavaThe pattern Strategy (Strategy) defines a family of algorithms, encapsulates and makes interchangeable. Allowing each...
OOP, an Introduction to Object-OrientationOOP was built to help manage complexificación software through abstraction. In POO, build small segments...
Inheritance between ObjectsBut the benefits of the objects do not stop ahí.Los objects also have a special...
POO, an introduction to object-oriented programmingObject-oriented design (OOD) is a programming methodology that has the following features: * OOD allows...
PolymorphismWell, there is one final feature of the objects you need to understand. * Objects...
Objects in POOThe beauty of the objects that can be used even if you do not know...
Classes in PHP languagesThe classes are greatest exponent of Object Oriented Programming (OOP). PHP is not an object...
Learn how to use Regular Expressions (Part 1)A regular expression is a set of characters and symbols that define a chain as...

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

No comments yet.

Sorry, the comment form is closed at this time.

  Popular posts Who is behind Freelancer-job ?   Top keywords
   

My name is Igor. Global economic crisis,  that began that year, gave us a lot of problems. Freelancers must choose  clients carefully now and this blog will help them. Here, everything is free - programmers can promote their skills for free giving comments, employers offer jobs for free. If  you want you can join me at Stumbleupon or Twitter or Digg. or Facebook

  Freelancers jobs - freelancer job - freelance needed - freelance wanted - freelance find - freelance salary - jobs hiring now