How to use state pattern correctly?

后端 未结 9 856
既然无缘
既然无缘 2021-01-29 21:54

I\'ve encountered a few implementations of state pattern in my programming experience, and done a few. I\'ve seen them used in various scenarios (mostly UI and parsing). The tro

9条回答
  •  攒了一身酷
    2021-01-29 22:12

    Just my 2 cents, the state pattern always turns to be hard to maintain as it is hard to understand by those who has not coded it. I usually fallback to old standard array of function/method pointers, as I've in my old C experience. You just build a two dimensions array of function pointers with state/signal for lines/columns. Easier to understand. you have a class that manage that and you delegate to other class to handle complexity ...

    my2c

提交回复
热议问题