I don't know if it has a name, but it looks like a fairly normal double-dispatch behavioral pattern which is common in UI/plugin frameworks (i.e. JSR-296), except there it's multicast (multiple observers/stakeholders) rather than unicast. I don't think it has anything more to do with continuations (encapsulated execution state) thank an iterator has, but the functional peops in here will likely speak out.
/Casper On Jun 14, 12:57 pm, Fabrizio Giudici <[email protected]> wrote: > You have a service, which is about getting some data by a getData() > method. Instead of synchronously returning the data, the method notifies > (possibly later) a callback: > > service.getData(callback); > > The callback exposes these methods: > > public interface Callback > { > public void notifyNoData(); > > public void notifyData (Datum datum); > > public void notifyDataCouldBeRetrieved (ConfirmationCallback > confirmationCallback); > } > > The first two methods are obvious. When the third is called, to confirm > the operation you have to call a doRetrieve() method on the > ConfirmationCallback: > > public interface ConfirmationCallback > { > public void doRetrieve(); > } > > I've been playing with this design since a few time for UI design; and > I'm going to blog about it. I usually refer to this as "async message > style", but I'm almost sture there's a more specific name for it. Which > one? Searching around it seems that there are some similarities with CPS > (Continuation-Passing Style), but I'm really dubious about that (my > understanding of Continuations is very different; but perhaps CPS is > different than "pure" Continuations?). I've found some references to > CPS, including some code samples, and some make me think this is CPS, > others not (especially those dealing with variations on tail recursion > or stackless implementations - perhaps they are just different scenarios > than mine, perhaps the CPS is a totally different thing). > > Help appreciated (biblio references too). > > PS Please don't post whether you like this design or not :-) I'll be > happy to later answer to comments to the blog post when it's ready. Now > I just need to complete the post with the proper terminology. > > -- > Fabrizio Giudici - Java Architect, Project Manager > Tidalwave s.a.s. - "We make Java work. Everywhere." > java.net/blog/fabriziogiudici -www.tidalwave.it/people > [email protected] -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
