mardi 12 mai 2020

Command pattern is the command a single instance

Does the definition for the command pattern tells if the command should be reusable. I mean are you supposed to create a new instance every time you want to call the execute-method or can you create a single instance of the command and call execute multiple times with different parameters?

Being on the .net platform, I can see that commands in WPF are only created once, not sure though that's the answer.

Perhaps another way to look at it, is a command disallowed to hold state, like a ddd-service, if so having a single instance would be fine.

If this is not part of the patterns definition, does any "best practices" exists?

Aucun commentaire:

Enregistrer un commentaire