Re: [The Java Posse] Re: Need to find the correct terminology for a pattern

2011-06-18 Thread Fabrizio Giudici

On 06/17/2011 11:40 PM, Kevin Wright wrote:




"1842 - Ada Lovelace writes the first program. She is hampered in her 
efforts by the minor inconvenience that she doesn't have any actual 
computers to run her code. Enterprise architects will later relearn 
her techniques in order to program in UML."


http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html

LOL. But of course UML is documenting and not programming. Despite of 
that, being picky in the use of stereotypes is as important as avoid 
misusing pattern names, or jeopardizing any consolidated vocabulary.


--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
fabrizio.giud...@tidalwave.it

--
You received this message because you are subscribed to the Google Groups "The Java 
Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.



Re: [The Java Posse] Re: Need to find the correct terminology for a pattern

2011-06-17 Thread Kevin Wright
On 17 June 2011 20:33, Fabrizio Giudici wrote:

> On 06/17/2011 06:49 PM, Kevin Wright wrote:
>
>>
>>
>> Agreed :)
>>
>> Phrases like "callback style" or even just "asynchronous" would probably
>> be more useful in this context, as they better reflect the intent of the
>> code.
>>
>>  A few days ago I updated the draft to just call for "similarities" with
> continuations (and that the design is "inspired" by CPS). Given that you're
> there, a final question: should I put an UML stereotype to my callback
> classes, do you think <> would be wrong? At this point, I
> think it would be imprecise. Probably <> is better.
>
>
>
"1842 - Ada Lovelace writes the first program. She is hampered in her
efforts by the minor inconvenience that she doesn't have any actual
computers to run her code. Enterprise architects will later relearn her
techniques in order to program in UML."

http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html



>
> --
> Fabrizio Giudici - Java Architect, Project Manager
> Tidalwave s.a.s. - "We make Java work. Everywhere."
> java.net/blog/fabriziogiudici - www.tidalwave.it/people
> fabrizio.giud...@tidalwave.it
>
>


-- 
Kevin Wright

gtalk / msn : kev.lee.wri...@gmail.com
mail: kevin.wri...@scalatechnology.com
vibe / skype: kev.lee.wright
quora: http://www.quora.com/Kevin-Wright
twitter: @thecoda

"My point today is that, if we wish to count lines of code, we should not
regard them as "lines produced" but as "lines spent": the current
conventional wisdom is so foolish as to book that count on the wrong side of
the ledger" ~ Dijkstra

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.



Re: [The Java Posse] Re: Need to find the correct terminology for a pattern

2011-06-17 Thread Fabrizio Giudici

On 06/17/2011 06:49 PM, Kevin Wright wrote:



Agreed :)

Phrases like "callback style" or even just "asynchronous" would 
probably be more useful in this context, as they better reflect the 
intent of the code.


A few days ago I updated the draft to just call for "similarities" with 
continuations (and that the design is "inspired" by CPS). Given that 
you're there, a final question: should I put an UML stereotype to my 
callback classes, do you think <> would be wrong? At this 
point, I think it would be imprecise. Probably <> is better.



--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
fabrizio.giud...@tidalwave.it

--
You received this message because you are subscribed to the Google Groups "The Java 
Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.



Re: [The Java Posse] Re: Need to find the correct terminology for a pattern

2011-06-17 Thread Kevin Wright
On 17 June 2011 14:00, Alessio Stalla  wrote:

> On Jun 14, 7:40 pm, Fabrizio Giudici 
> wrote:
> > On 06/14/2011 02:11 PM, Kevin Wright wrote:
> >
> > > The current approach taken by Scala/C# is therefore reification of
> > > *delimited* continuations to stop you blowing the stack.  This isn't
> > > exactly an easy thing to get right, hence the fact that it's a fairly
> > > recent arrival (the growing popularity of asynchronous designs, and
> > > the usefulness of continuations for these have also helped spur
> adoption)
> >
> > Is this the part related to CPS and tail recursion, right? Not related
> > to my post, but since I'm here, perhaps I can start understanding
> > something around.
> >
> > So, if in my post I refer to my example as a very simple CPS, I sholdn't
> > be bashed. By Kevin at least :-)
>
> Hi Fabrizio :) I'm no expert in functional programming, but
> nevertheless I have some understanding of continuations.
> Code written in CPS has only function calls without return statements:
> "returning" a value means calling a function (called a continuation).
> So, in a naive implementation, the progress of the computation
> eventually blows the stack. Tail call optimization or TCO (a
> generalization of tail recursion) is a way to perform certain function
> calls without consuming stack space, translating them into jumps.
> Since luckily in code written in CPS all calls to continuations are
> "in tail position" and thus eligible for TCO, that is a way to
> implement CPS without using too much stack space.
> Note however, to add some confusion ;), that user code is rarely
> written in CPS in general; transformation to CPS is a technique used
> in certain compilers, not necessarily to implement continuations (that
> can be implemented with other techniques as well).
>
> To return to your original example, I have not clear the effect of
> calling doRetrieve() since it doesn't return anything and it doesn't
> take any argument. Does it make the service invoke notifyDatum()? In
> that case, yes, I'd say it's a form of CPS :) although I believe CPS
> can hardly be called a pattern since it doesn't solve a specific
> problem, it's too generic, in my opinion.
>
>
Agreed :)

Phrases like "callback style" or even just "asynchronous" would probably be
more useful in this context, as they better reflect the intent of the code.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.



[The Java Posse] Re: Need to find the correct terminology for a pattern

2011-06-17 Thread Alessio Stalla
On Jun 14, 7:40 pm, Fabrizio Giudici 
wrote:
> On 06/14/2011 02:11 PM, Kevin Wright wrote:
>
> > The current approach taken by Scala/C# is therefore reification of
> > *delimited* continuations to stop you blowing the stack.  This isn't
> > exactly an easy thing to get right, hence the fact that it's a fairly
> > recent arrival (the growing popularity of asynchronous designs, and
> > the usefulness of continuations for these have also helped spur adoption)
>
> Is this the part related to CPS and tail recursion, right? Not related
> to my post, but since I'm here, perhaps I can start understanding
> something around.
>
> So, if in my post I refer to my example as a very simple CPS, I sholdn't
> be bashed. By Kevin at least :-)

Hi Fabrizio :) I'm no expert in functional programming, but
nevertheless I have some understanding of continuations.
Code written in CPS has only function calls without return statements:
"returning" a value means calling a function (called a continuation).
So, in a naive implementation, the progress of the computation
eventually blows the stack. Tail call optimization or TCO (a
generalization of tail recursion) is a way to perform certain function
calls without consuming stack space, translating them into jumps.
Since luckily in code written in CPS all calls to continuations are
"in tail position" and thus eligible for TCO, that is a way to
implement CPS without using too much stack space.
Note however, to add some confusion ;), that user code is rarely
written in CPS in general; transformation to CPS is a technique used
in certain compilers, not necessarily to implement continuations (that
can be implemented with other techniques as well).

To return to your original example, I have not clear the effect of
calling doRetrieve() since it doesn't return anything and it doesn't
take any argument. Does it make the service invoke notifyDatum()? In
that case, yes, I'd say it's a form of CPS :) although I believe CPS
can hardly be called a pattern since it doesn't solve a specific
problem, it's too generic, in my opinion.

Cheers,
Alessio

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.



[The Java Posse] Re: Need to find the correct terminology for a pattern

2011-06-14 Thread Casper Bang
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 
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
> fabrizio.giud...@tidalwave.it

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.