State Transition Operation

Published: 20 August 2023

Known Uses

In the Dutch Energy sector, the State Transition Operation pattern is commonly used in workflow management implementations that assign work tasks to contractors involved in the operational maintenance of the energy infrastructure network. Another known use is the sector-wide customer support ticket management platform. In this scenario, the API operations manage state in the ticket lifecycle algorithm.

Discussion Input

It’s good to distinguish between the terms “State Transition” and “State Transfer”. The “State Transition Operation” pattern takes state as input and modifies the provider-side application state, whereas “State Transfer Operation” does require state input in order to modify the state. To put the different terms in the functional notation as used in the book:

State Transition Operation: (in, S) -> (out, S')

State Transfer Operation: in -> (out, S')

“State Transition” corresponds nicely to Command Message in the Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf: messages with the intent to change the state of the system. They are actions to be performed that have side effects. “State Transfer” corresponds to Event Messages: events are things that have happened within a system. They are the result (not in the method/return sense) of an executed command. Consider in this context the term “Event Carried State Transfer”. In the book, “State Transfer Operation” is not used, but the term “State Creation Operation” is used instead. This is all explained in the “Notes from The Architecture and Modeling Learning Event”; we found the mapping of these terms to EIP very useful.

There was an interesting discussion on LinkedIn on the functional notation used in the book for the different operation responsibilities. How would a delete operation (do) be notated? Since it does affect the state and it is a variant of State Transition Operation (sto) it would advisable to use the same notation as for sto:

do: (in, S) -> (out, S')

However, what’s the added value of sending a response back when deleting? in HTTP APIs, one of the commonly used status codes reporting a successful deletion is a ‘204’ — which stands for: ‘No Content’ — which means ‘no response payload’ and since delete affects the state, perhaps the following notation would help for expressing the delete operation (do):

do: (in, S) -> S'

Read the complete pattern on api-patterns.org

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top