Linked by Eugenia Loli on Sun 22nd Apr 2007 07:43 UTC
.NET (dotGNU too) 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.
Order by: Score:
It is a shame
by joshv on Sun 22nd Apr 2007 12:45 UTC
joshv
Member since:
2006-03-18

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.

Reply Score: 2

RE: It is a shame
by Matzon on Sun 22nd Apr 2007 13:28 UTC in reply to "It is a shame"
Matzon Member since:
2005-07-06

I do so hope that was ironic...

Reply Score: 1

RE[2]: It is a shame
by joshv on Sun 22nd Apr 2007 15:56 UTC in reply to "RE: It is a shame"
joshv Member since:
2006-03-18

No, I was serious.

Reply Score: 2

RE[3]: It is a shame
by Matzon on Sun 22nd Apr 2007 16:37 UTC in reply to "RE[2]: It is a shame"
Matzon Member since:
2005-07-06

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

Reply Score: 2

RE[4]: It is a shame
by joshv on Sun 22nd Apr 2007 17:37 UTC in reply to "RE[3]: It is a shame"
joshv Member since:
2006-03-18

Next time I will use the slashdot-style [sarcasm][/sarcasm] tags.

Reply Score: 2

RE: It is a shame
by nberardi on Sun 22nd Apr 2007 15:09 UTC in reply to "It is a shame"
nberardi Member since:
2005-07-10

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?

Reply Score: 1

RE[2]: It is a shame
by jayson.knight on Sun 22nd Apr 2007 18:43 UTC in reply to "RE: It is a shame"
jayson.knight Member since:
2005-07-06

"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 ;-).

Reply Score: 3

RE[3]: It is a shame
by nberardi on Sun 22nd Apr 2007 22:37 UTC in reply to "RE[2]: It is a shame"
nberardi Member since:
2005-07-10

Yeah I am just going to assume that this author closely relates to this article. http://worsethanfailure.com/Articles/The_Complicator_0x27_s_Bicycle...

Reply Score: 2

Events are the way to go!
by siimo on Mon 23rd Apr 2007 02:05 UTC
siimo
Member since:
2006-06-22

Events and delegates are cool. Not sure why this author has to do it the hard way.

Reply Score: 1