Design scheme for switching or cycling between states

Is there a design template (for example, visitor, strategy, state, etc.) or some other design principle to help develop a good solution for modeling flow in states for an object, such as Task .

The task starts with the status New , then goes to the status of BeingHandled , then WaitingForApproval , and then it can be moved to Finish or NotApproved , which essentially refers to BeingHandled with additional information, saying that it has returned from WaitingForApproval .

So, in the general case, we have a common flow, and then there can be some internal flow inside it.

Thanks,

ashilon

+4
source share
3 answers

This is not a template, but a concept: a finite state machine .

Thus, it is a finite state machine that can only have an active state at a time.

See what the Wikipedia article says in its first paragraph:

(FSM) ( : ), , , , . , . ; , , . , ; . FSM , .

+6

, - .

/ /. , WaitingForApproval, , NotApproved ..

, ( ) , /, - .

, , State Base. , "" , . IllegalOperations . currentState state-handler.

, , , currentState- . factory .

, ... , ... , - .

, , - http://www.javabrahman.com/design-patterns/state-design-pattern-in-java/

+2

"", "", "", "" " ", "" , , WaitingForApproval.

, (FSM) - , . - , , , .

, FSM ( ), , , , . , . PlantUML PlantText.com , .

- ( ), . , , New BeingHandled , , . , BeingHandled WaitingForApproval , , , - / . .

Finite state machine for task objects in PlantUML

, , ( ). , ( , , ). FSM . FSM- Java Google.

+1

Source: https://habr.com/ru/post/1615210/


All Articles