Command Pattern : How to pass parameters to a command ?
- by Romain Verdier
My question is related to the command pattern, where we have the following abstraction (C# code) :
public interface ICommand
{
Execute();
}
Let's take a simple concrete command, which aims to delete an entity from our application. A Person instance, for example.
I'll have a DeletePersonCommand, which implements ICommand. This command needs the Person to delete as a parameter, in order to delete it when Execute method is called.
What is the best way to manage parametrized commands ? How to pass parameters to commands, before executing them ?