looks ugly and does not offer any significant advantage in terms of readability and maintenability.
The main problem I see is that you have to retrieve the references to those objects you created before you send the command thus making the program more coupled. It gives too much control on who should receive the message.
What I would like to see is a general message dispatcher that any interested party can subscribe to action types. That way you have a more decoupled way of dealing with actions and effects. The sender won't have to know details.
Another approach is to provide a message type (instead of an address) and implement a message routing mechanism. Multiple strategies can be used in this mechanism.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sorry but this way of sending commands:
looks ugly and does not offer any significant advantage in terms of readability and maintenability.
The main problem I see is that you have to retrieve the references to those objects you created before you send the command thus making the program more coupled. It gives too much control on who should receive the message.
What I would like to see is a general message dispatcher that any interested party can subscribe to action types. That way you have a more decoupled way of dealing with actions and effects. The sender won't have to know details.
Another approach is to provide a message type (instead of an address) and implement a message routing mechanism. Multiple strategies can be used in this mechanism.