What is the Action Design Pattern, I haven't heard of it before? I am suspecting it is the same as the Command Design pattern [wikipedia] but I can't find any resources on it.
You're right, action pattern == command pattern. You hear it called the action pattern more often in GUI design, in the form "on some button pressed, perform this action". In the code the button would be wired up with an action object of some kind.
Action design pattern is same as Command design pattern. Action is a key entity, which encapsulates information with in itself regarding what's its behavior, what processing have to be done on its do() method, how it can be undone, and so on. When an application or any of its components is designed in accordance with Action design pattern, then Everything activity in the application can be represented in the form of action, every thing can be redone/undone several times. Eg. Macros in excel, Undo/redo in text-editors, etc.
Action class, which is a building block in this design pattern can be designed as below :-
public interface Action{
public void do();
public void undo();
public void do(int iNoOfTimes);
}
public class FileCopyAction implements Action{
private int iActionId;
public void do(){}
public void undo(){}
public void do(int iNoOfItems){}
}
Hope it helps.
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