What is the difference between the Strategy pattern and the Command pattern? I am also looking for some examples in Java.
Words are already given. Here is the difference in concrete code.
public class ConcreteStrategy implements BaseStrategy {
@Override
public void execute(Object argument) {
// Work with passed-in argument.
}
}
public class ConcreteCommand implements BaseCommand {
private Object argument;
public ConcreteCommand(Object argument) {
this.argument = argument;
}
@Override
public void execute() {
// Work with own state.
}
}