[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [computer-go] Event-driven programming




dear peter,

i think, i did something like what you call "event-driven programming".
i use a singleton which i call a NotificationServer and which handles all
the message passing:

so if object A wants to report an event it calls...

	NotificationServer.instance().notifyEvent( this, "some message" );

	note: i include a reference to the sending object (this), so that
	      a receiving object may talk to the sending object, if
	      nescessary

...and if object B wants to get notified by an event, it calls the
following on startup (e.g.):

	NotificationServer.instance().addListener( this, "some message" );

Then, if the NotifificationServer gets a notifyEvent() message, it works
its list of listeners and calls their worldChanged() method or whatever
you like to name it in your definition of the listener interface.


i think, this kind of programming addresses well the problem, that
this "who is gonna talk to whom?" stuff is often independent from
the "this object is a part of this object" assembling in object oriented
programming.
you don't have to pass around each objects reference to get the right
objects talk to each other. just have your NotificationServer available
in the classpath...

i hope, this helps you a bit...
(any "low-level programming challenges" left?)


bye,

	patrick



btw: i would call this "event-driven programming", too.
     in the real world ;) there are many examples of
     different subject areas having different notions of
     the same word.


On Thu, 15 Jan 2004, Peter Drake wrote:

> Is anyone using event-driven programming for Go?  (This is a variation
> on object-oriented programming where a message can be sent to many
> recipients and the sender doesn't have to know who they are.)
>
> The advantage, as I see it, is that various entities (pattern matchers,
> miai, groups, connections) can listen to only the board points that
> interest them.  When a play is made, only the interested parties are
> updated.

> There are some interesting low-level programming challenges, and we'll
> also have to be careful to do just the right amount of propagation...
>
_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://computer-go.org/mailman/listinfo/computer-go