# 108 - Learning the Observer Pattern


5/7/2009
Level: Intermediate
Tags: Design Patterns
Comments: (9)
Author:
Derik Whittaker


In this episode we will take at how we can use the Observer Pattern in our application.

The Observer pattern allows you to define a one-to-many relationship inside your application where the parent object (the one) has the ability to notify the child objects (the many) of any state change. You can utilize this pattern to make sure that a set of objects are keep in order when there behavior needs to change based on the state of your application.
Click here to Watch this Episode

Download (14.70 MB) (12:09) (1440x900)
Download (10.35 MB) (12:09) (960x600)

Links/Resources:


Comments: (9)

David Thibault said....

In .Net, you can also implement the observer pattern using events.

There are cases for both approaches. I'd start off with events for the simple scenarios and migrate them to the way you showed for more complex situations.


5/7/2009 9:14:20 AM

Dimecasts said....

@Dave,

Actually I have already recorded another episode showing how to implement the pattern in this way :)

Should be out in a few weeks.


5/7/2009 9:32:54 AM

Nisar Khan said....

thanks for screen cast.

is there a way i can download the sample?

thanks.


5/8/2009 1:19:34 PM

Dimecasts said....

@Nisar,

There is a link for the source in the links section


5/8/2009 1:42:38 PM

Nisar Khan said....

Thanks :)


5/8/2009 3:58:16 PM

Sheraz Khan said....

I personally don't like to implement observer pattern using events. Using abstraction (abstract class or interface) is the best way to go. If events are used, subject would have to know of the observer, while using abstraction subject (warehouse in this case) doesn't need to know who the cliet is as long as it implements the interface (or inherit from the abstract class)

 


5/13/2009 2:44:15 PM

Philippe Hertzog said....

Hello,

Nice example but I would have added 2 interfaces in your example (IObservable and IObserver for example) in order to decouple a little more the observers from observed object.

 


5/14/2009 5:43:27 AM

sexy lingerie said....

Fashion and <a href="http://www.yo2underwear.com">sexy lingerie</a> are cheap now,it's really wonderful,<a href="http://www.yo2underwear.com/corsets-bustiers-c-1.html">cheap corsets bustiers</a>.


3/13/2010 11:26:55 PM



Name: *
Email (not displayed): *
Url:
Comments: *



So, you Human...?