Command Pattern : How to pass parameters to a command ?

Posted by Romain Verdier on Stack Overflow See other posts from Stack Overflow or by Romain Verdier
Published on 2008-09-19T19:44:20Z Indexed on 2010/03/21 5:41 UTC
Read the original article Hit count: 311

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 ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about best-practices