|
|
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)
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. |
@Dave, Actually I have already recorded another episode showing how to implement the pattern in this way :) Should be out in a few weeks. |
thanks for screen cast. is there a way i can download the sample? thanks. |
@Nisar, There is a link for the source in the links section |
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) |
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. |
|
|