good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Cutting repetition in POE codingby nicholasrperez (Monk) |
on Nov 26, 2005 at 23:29 UTC ( [id://511962]=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|