Tomáš Votruba: The Bulletproof Event Naming For Symfony Event Dispatcher
In a recent post to his site Tomáš Votruba shares what he sees as a "bulletproof" event naming scheme for use with the Symfony event dispatcher component.
I wrote intro to SymfonyEventDispatcher and how to use it with simple event.
But when it comes to dispatching events, you can choose from 4 different ways. Which one to choose and why? Today I will show you pros and cons of them to make it easier for you.
He then breaks up the remainder of the post into the four suggestions, each with code examples and brief descriptions:
- Start with Stringly
- Group File with Events Names as Constants
- ...Constant Names in Particular Event Classes
- Class-based Event Naming
For each he also includes some "pros" and "cons" to help you select which one might work best for your usage. He ends by taking things "a step further" and sharing integrating a suggestion to remove an argument and simplify the code.