How is the statemachine model when the state is function dependent?

I have a contract class. The contract is valid from January 1, 2010 - December 31, 2010.

It can be in Active or Passive state, depending on what date I request from the instance for it. ex. if I ask on July 4, 2010, it is in Active state, but if I ask on January 1, 2011, it is in Passive state.

Statemachine Chart:

From the β€œStart” state, in what state should I go to the next? I think that the default pseudo-state is with an input function that determines which state to go to next, and then to the substitution machine with active and passive, and then to the completion state when deleted.

But it seems complicated for such a trivial task.

How do you do this?

+1
source share
1 answer

Hmm, you want to either do what you described, which will allow the Contract to be invalid (start / end) when someone tries to use a contact without an event of a prior date, or you can try to add a call to this function in the constructor, so your contract is in correct condition immediately. There may be other solutions, but you should consider what other events (calls to messages / methods) may occur in the contract than the date. Some may affect stae. BTW. your decision is not so difficult when, instead of embedding a finite state machine, you only connect the beginning and the end with active and passive states.

0
source

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


All Articles