Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What alternatives are there to modelling complex behaviour with finite state machines? [closed]

I have read about a lot of disadvantages of using finite state machines but haven't really seen any alternative patterns for modelling complex behaviour suggested- are there any?

like image 892
fordeka Avatar asked Jan 23 '13 02:01

fordeka


People also ask

What are alternative forms of finite state machine?

There are two types of finite automaton, Deterministic (DFA) and Nondeterministic (NFA). Both of them accept regular languages and operate more or less in the same way described above however with some differences.

What types of systems would you use a finite state machine as a model for?

In computer science, finite-state machines are widely used in modeling of application behavior (control theory), design of hardware digital systems, software engineering, compilers, network protocols, and computational linguistics.

What are the two types of finite state machines?

Finite-state machines are of two types – deterministic finite-state machines and non-deterministic finite-state machines.


1 Answers

Could you give us some references? I generally see FSMs written about in glowing terms. If you truly have an FSM, they are not that difficult to implement and they have a lot of advantages. A lot of times, though, people think they have an FSM, but what they really have is some simple procedural thing that proceeds through a few steps. If that's the case, then the key alternative to consider is the design pattern Template Method.

Where FSMs really shine, doing things above and beyond what could be done with Template Method, is when there are constraints about progression from one stage to another. For example, if we were modeling something like the preparation of a tax return, all the preliminary collection of earnings and the computation of gross wages is done in the first stage and there should be no way to start computing deductions until the wages are complete. (This is a contrived example, but imagine that there are other preconditions on state transitions.)

Template Method, per the example in the Gang of Four, makes it possible to enforce in an abstract class the fact that certain actions have to proceed through a sequence of steps, in order. The interesting thing about Template Method is that you are hiding those details and forcing the subclasser to simply provide implementations of the required steps/methods.

like image 55
Rob Avatar answered Oct 07 '22 21:10

Rob