Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I've not thought it through in detail, but I envisage a forward_message method on your CDAT object that disallows recursive calls with the same message object. Consider:

sub forward_message { my ($self, $message) = @_; return undef if exists $self->{activeMessages}{$message->id_hash}; $self->{activeMessages}{$message->id_hash} = 1; # forward messages to all objects. Objects determine applicability delete $self->{activeMessages}{$message->{id_hash}}; return 1; }

Note that both CDAT and the message are objects and retain state. Messages may trigger the immediate processing of more messages, but reprocessing "identical" messages is prohibited. The id_hash determines what is considered to be "identical".

The idea of dynamic dispatch appeals to me for this application so I'd likely have a chunk of code in the target objects's message handlers that looks like:

sub message_handler { my ($self, $message) = @_ my $handler = 'handler_' . $message->{action}; return undef if ! $self->can ($handler); return $self->$handler ($message); } sub handler_addTaxonName { my ($self, $message) = @_; my $newTaxon = $message->{newTaxon}; ... my $balance = $self->create_message ('rebalance', -taxon => $newTa +xon, ...); $self->{CDAT}->forward_message ($balance); return 1; } sub handler_rebalance { my ($self, $message) = @_; my $newTaxon = $message->{newTaxon}; ... }

DWIM is Perl's answer to Gödel

In reply to Re^3: design suggestions for object integration wanted by GrandFather
in thread design suggestions for object integration wanted by rvosa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found