Is is common to use the command pattern for property get/sets?
- by k rey
Suppose I have a controller class with a bunch of properties. Each time a property is changed, I would like to update the model. Now also suppose that I use the command pattern to perform model updates. Is it common to use command classes within property get and sets of the controller class or is there a better way?
Here is an example of what I am currently using:
class MyController {
private int _myInt;
public int MyInt {
get { return _myInt; }
set {
MyCommand cmd = new MyCommand();
cmd.Argument = _myInt;
cmd.Execute(); // Command object updates the model
}
}
}