Improving Project Scalability
Last updated
Last updated
The primary issue I've found with global broadcasting systems is that once a project gets big, it gets difficult to track down what messages and channels are available and it becomes hard to resolve which channel and what struct to use.
The debugger already helps, but it still allows developers to make mistakes when filling out either the channel or message type.
I recommend creating macro libraries with the parent class set to Object
, then name it after a specific struct.
Then inside of this library, you create "Broadcast" and "Listen" macros where you pre-assign the channel and struct type.
Now your code can look like this:
This greatly reduces the risk of someone using the wrong tag and/or wrong struct when trying to interact with someone else's message.
A neat side effect of this method is that if you give your macros a category, you can now populate your context menu with all broadcasts and listen events that have been setup, with a more clean name and optionally a code comment.