Open VladymyrPylypchatin opened 3 hours ago
Yes, an object typically has only one state at a given point in time in a state machine or lifecycle model. This is a core principle of state machines, which ensure that an object is in a clearly defined state at any moment. The object can only transition between states based on specific events or conditions, and it cannot be in multiple states simultaneously.
Key Points: Single State Principle: An object can be in only one state at a time. For example, a payment object cannot be both in a "Processing" state and a "Succeeded" state at the same time.
State Transitions: The object moves from one state to another based on triggers, actions, or events. For example, a Payment Intent in Stripe might transition from requires_payment_method to requires_confirmation once a payment method is provided.
Sequential Progression: The object progresses through its lifecycle in a well-defined sequence of states. Once it moves to a new state, the previous state is no longer active.
The key part here is after every step you can check its status to see what needs to happen next
Object lifecycle statuses should inform what Action should you take next.
Also I think another important part there is difference between Stage and State/status.
State/status is what an object is.
Stage is what activity is happens within the process.
E.g. Status: Payment Intent IS Confirmed Stage: Processing -> system does processing of the payment intent
Since we have an object-oriented system design, objects are the system's foundation.
It would be handy to be able to standartaise how we define object lifecycle and manage it.
Everything is an object.
Every object have live.
How we can standardise definition of object lives
Love the explanation here: https://docs.stripe.com/payments-api/tour
> Everything is an object