0

These days, I am learning Gof design patterns in C# and I think event-handling might have something to do with Observer pattern. My question is while solving problems with events and their handlers, why we still need observer pattern?

1 Answers1

1

Your question is comparing apples and pears.

The observer pattern is a solution to a problem. It doesn't tell you how to implement the solution, but is more like a blue print.

Thus, the event model in .NET is an implementation of the observer pattern. The EventHandler delegate is defining the observer and the event keyword takes care of dealing with all notifications in the subject, just as defined in the observer pattern.

jgauffin
  • 99,844
  • 45
  • 235
  • 372