Several runtime listeners vs one for the whole game

Hi, 

With regards to performance, is it better to get everything (all control structures) that you need to run in runtime inside a big fuction with a single runtime listener for the game?,

or have several functions with a runtime listener each (several runtime listeners for the game)?

Thanks

@elpilotojavier,

I suggest using multiple listeners.  Event driven programming should be light-weight.  Once you move all your code into a single listener you’ve defeated the purpose of that model. 

I generally make my listeners responsible for small pieces of the game and mostly ignorant of what else is going on.   

That said, if you have 1000’s of listeners, you’ll run into other problems.  So, as with all things, it is a question of moderation and balance.

To start, I would write specific/targeted listeners that do one (or a few) things based on the event(s) they track.  Then, if you feel like your performance lags or that consolidating might help performance, try it.

Thanks a lot for the pront reply.

@elpilotojavier,

I suggest using multiple listeners.  Event driven programming should be light-weight.  Once you move all your code into a single listener you’ve defeated the purpose of that model. 

I generally make my listeners responsible for small pieces of the game and mostly ignorant of what else is going on.   

That said, if you have 1000’s of listeners, you’ll run into other problems.  So, as with all things, it is a question of moderation and balance.

To start, I would write specific/targeted listeners that do one (or a few) things based on the event(s) they track.  Then, if you feel like your performance lags or that consolidating might help performance, try it.

Thanks a lot for the pront reply.