Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Cutting repetition in POE coding

by nicholasrperez (Monk)
on Nov 26, 2005 at 23:29 UTC ( [id://511962]=note: print w/replies, xml ) Need Help??


in reply to Cutting repetition in POE coding

Rigorously checking that condition is probably unavoidable. It sounds like this core event is tied to a wheel or perhaps a component that is feeding you information and then you are delegating the processing of that data to other specialized sessions. Inherently, there is nothing wrong with an if/else statement based on that condition even if it is a bit repetitive. The problem with trying to do overly clever based event dispatching is that unless you specifically validate the incoming information, someone maybe able to send you malformed data that causes your program to fire the wrong event. And then if you are going through all the trouble of validating the information you might as well go back to the if/else statement to do the dispatching.

As an aside, if you really have that many events and sessions to which you are dispatching, then perhaps you need to conglomerate a bit more and build a second tier for processing and have your events trickle down to keep things a bit more simple. Of course without an overall picture it is difficult to know if this really is the case with your program or not.

-- Nick

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://511962]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-28 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found