I was trying to use the state pattern in a DDD aggregate, but I was thinking in the following alternative.
In sumary, the state pattern controls what actions can be done in each state. This makes to create one class of each possible state and implement it. So if I want to add a new state I have to modify the code.
I was thinking in this alternative. To have a table States in my database, with one column for each possible action the tell if it is possible or not. Something like that:
State(ID, Name, CanDoAction1, CanDoAction2..., CanGoToSate1, canGoToState2,...)
So in my domain, the order aggregate only needs to have the information of the state, and to see if it is possible to do or not according of the state.
This avoid the use of inheritance to implement the state pattern, and the code would be simplier.
But I don't know if this a good option or not.
Another motivation is that using state pattern, I am not able to configure EF to use state as value object because I am not able to configure the state as owned entity, but this would be another history for another post.
Thanks.