3 ms·
In your example, what happens if changes need to be made to the protocol? It is less frequent than business/application changes, but definitely can happen.
by teacpde 6y ago
In your example, what happens if changes need to be made to the protocol? It is less frequent than business/application changes, but definitely can happen.
- lmilcin 6y agoGood protocols are usually made in layers. You would typically want to have some state machine describing lower part of application protocol on which you build higher level of your application protocol, composed of specific functions. This way you can modify functionality without necessarily touching low level implementation. I can give an example. I have worked with credit card terminals and I have implemented entire application from scratch. There is a protocol to communicate between the terminal and the acquirer's system (ISO 8583). This protocol specifies a flow and format of messages. For example, if you send a transaction request, you will get a response. If you don't get a response you may or may not retry it, etc. If you send a transaction advice (ie. transaction has already happened) you must be retrying sending it until you get a response, but every retransmission after first must include a bit that says it is retransmission. If the request or advice has been sent and transaction was cancelled, you need to be sending cancellations until you get an acknowledgement. Now, all those messages have a huge amount of fields that change regularly as requirements change, but the basic flow of the protocol is fairly constant and has been constant for many years. I have implemented the protocol as a tree of state machines telling the application what to do based on events and I believe the code has not been touched in over 10 years even though the application was in constant development.
- megameter 6y agoAs parent has noted, FSM models are flexible boundary abstractions and you can apply them repeatedly to reach the desired level of granularity. For example, you might start with a large block of code with many inputs and many side effects. You can map this block of code into a FSM directly - as a "giant switch statement" of all conditional combinations and copy-pasted side effects - or you can devise a way of specifying it that makes it an "input FSM" and an "output FSM" where the input FSM enumerates the types of side effects, and the output FSM acts upon them. You can also hybridize FSM behaviors with simple constraint optimization to create "smart" solvers: Define a heuristic for solution goodness. Then run the FSM speculatively with various combinations of inputs and rank which combo best fits the heuristic.