I am working on an application and trying to follow Robert C. Martin's SOLID principles. I am using the Command Pattern and I was wondering about the implementation. In all of his examples in Clean Code and Agile Principles, Patterns and Practices in C# his command objects never return anything. His Command interface is;
public interface Command
{
void Execute();
}
All of the examples are "AddEmployee", "DelEmployee", "EditEmployee", etc. Would I have a command that would be "GetAllEmployees" or is there some other special "Interactor" I would create for that specific purpose? One way I am thinking of handling that specific case is to have two interfaces a non generic like the one above and a generic one like this;
public interface Command<T>
{
T Execute();
}
What I am asking is would this be an acceptable implementation of this pattern or is there another way we would access data from the application?
A command is something that changes state (updates, deletes or additions).
When getting data (and not changing it), you would use a query.
Also see CQS and the related CQRS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With