On Thu, May 23, 2002 at 03:31:43PM -0400, Peter Chen wrote:
> I would like to solicit your insight on the best practices in handling
> responses/postbacks.  Specifically, I am wondering what are the pro's
> and con's of using a response event vs. a response postback.  For
> example,

[simple post vs. postback]

> In the various components I have surveyed (PoCoCl::DNS, PoCoCl::HTTP,
> PoCoCl::Ping, PoCoCl::UA, PoCoCL::POP3, PoCo::SubWrapper), both styles
> are used.

POE::Component::IRC uses a variation of simple posts.  A "client"
session registers the PoCo::IRC events it's interested in.  The
component then sends those events as they happen.

POE::Component::Client::POP3 uses an interesting variation on this
subscription model.

> A couple advantages of using postbacks that I can think of are
> 
> 1. The ability to include state arguments.
> 2. More generalized, i.e., it works with functions outside of POE.

These are the two fundamental reasons postbacks were created.  They
were then adopted by early components as a quick (and already
implemented) way to pass requests and responses.

Postbacks are cumbersome for message passing in larger programs.

On Thu, May 23, 2002 at 04:18:09PM -0400, Kirill wrote:
>
> 3. They hold a reference to your object and so help it stay in memory.
> IIRC that was the reason postbacks were chosen for PoCoCl::UA.

Since the creation of postbacks, two changes have occurred to make
them nearly obsolete for inter-session (and session/component)
messaging.

First, POE::Kernel gained refcount_increment() and -decrement()
methods, so one session could alter the reference count of another.
Components can now hold their clients active for the duration of one
or more transactions.

Second, posted events keep their senders alive.  This eliminated the
need for ugly hacks like inter-session call() and the "smileyninja"
alias in all the POE::Component::IRC examples.

> I am certain that many of you have more profound insights in the
> matter.  TIA.

This issue haunts my every waking moment. :) Seriously, a long time
ago several people said POE needed a consistent messaging system.  As
I've used it more, it's become painfully clear they were right.

I have rough designs for a few ways to pass messages between
components.  None of them feels quite right, so we still don't have a
standard.  If I were to write a messaging manifesto summarizing them,
would people be interested in discussing them towards the goal of
creating one tidy system?

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net

Reply via email to