All too often, source code spends a lot of time on basic housekeeping, monitoring the state of many objects. This is wasteful, and with C# it is unnecessary. Software expert Stephen Morris shows how C# provides a range of callback mechanisms that obviate the need for polling objects for state information.
Yeah, it’s a shame, all that polling logic I’ve written in Java because I don’t understand how to use java.util.Observable, or the various event listener interfaces most frameworks provide.
I do so hope that was ironic…
No, I was serious.
The Observer pattern is one of the most used patterns (except maybe for Singleton). It’s easy to implement and use – and to understand!
You might want to read the following book, which should be in every OO programmers library:
Design Patterns: Elements of Reusable Object-Oriented Software
Next time I will use the slashdot-style [sarcasm][/sarcasm] tags.
I thought this is why we used the delegate event model, or the event subscriber model, so that we didn’t have to monitor all this stuff?
“I thought this is why we used the delegate event model, or the event subscriber model, so that we didn’t have to monitor all this stuff?”
You are absolutely 100% correct. I have no idea why the author went through all the pains of setting up all the callbacks/polling/whatever you want to call it, by hand in this example when delegates (Name EventHandler delegates) would have more than sufficed, as well as made the code much more readable, and smaller.
It’s almost like he went out of his way to do it the Java way ;-).
Yeah I am just going to assume that this author closely relates to this article. http://worsethanfailure.com/Articles/The_Complicator_0x27_s_Bicycle…
Events and delegates are cool. Not sure why this author has to do it the hard way.