7

I am studying for an exam and a question on one of the previous exams is:

enter image description here

A lot of answers on the web are saying Statecharts and Statemachines are the same thing? If not could someone explain the difference in relation to this question.

If someone could give examples of both it would really help. Thanks

user3541209
  • 135
  • 2
  • 8
  • Possible duplicate of [Does statemachine and statechart mean the same?](http://stackoverflow.com/questions/8192724/does-statemachine-and-statechart-mean-the-same) – qwerty_so May 04 '16 at 18:34
  • I saw this but still don't understand the differences. Is there somewhere I can find an example of a state chart and a state machine side by side – user3541209 May 04 '16 at 19:39
  • They are almost the same. UML Spec: The specific form of finite state automata used in UML is based on an object-oriented variant of David Harel’s statecharts formalism. – qwerty_so May 04 '16 at 19:51
  • Sorry but I don't see how this explains the differences – user3541209 May 04 '16 at 20:15
  • Didn't I say "They are almost the same."? – qwerty_so May 04 '16 at 20:20
  • Welcome to StackOverflow, @user3541209. If you found an answer to your question, please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) (by clicking the check-mark), and consider up-voting it (by clicking the up arrow). Accepting an answer indicates to the wider community that you've found a solution, gives yourself some reputation points, and gives some reputation points to the person who answered your question. If you did not find a satisfactory answer to your question, please leave a comment. – Jim L. May 13 '16 at 02:30

4 Answers4

12

A statechart is quite different from a finite state machine (I am assuming that this is what is meant by "conventional" state machine). Statecharts refer to Harel's notation invented in 1984, which was proposed as a significant notational extension over traditional finite state machines.

Statecharts have been incorporated in the UML language (although they refer to it as behavioural state machines, and UML also supports another notion called protocol state machines to add to the confusion).

The main important differences are that statecharts are actually a kind of "hierarchical" state machines. States can contain nested state machines (at any level of depth). In addition to this, the notion of orthogonal regions has been added to model different sub-statecharts running in parallel, and the notion of history states (either shallow history or deep history) can be used to remember which substate to visit when re-entering a composite state.

All of these extra features make statecharts much more scalable and expressive than simple, flat, state machines. Statecharts also allow adding actions associated with events (either inside a state or on a transition between states).

Many different (often commercial) tools exist that allow to fully generate executable code from a statechart or to simulate model behaviour (e.g. StateMate, Rhapsody, Stateflow, Yakindu Statechart Tools, visualSTATE, and many more). They are also frequently used in industry, mostly in the domain of embedded and reactive systems.

This is why statecharts can be considered as one of the success stories of executable modelling.

Adithya Sreyaj
  • 769
  • 5
  • 16
Tom Mens
  • 131
  • 1
  • 3
0

A state machine is a mathematical model of computation that is less general purpose than a Turing Machine. Another common usage of the term "state machine" is the code that implements that model and runs on a computer.

In contrast, a state chart is a description of a state machine, usually represented as a diagram or a table. The word "chart" is Latin for "paper", so it implies something written or drawn.

There are many kinds of state machines, including Mealy, Moore, and Harel. (Whether Harel defined a kind of state machine formalism or just a better state chart notation is unclear to me.) UML is a superset of those, with one unified surface notation for the underlying model. Both the model and the graphical notation describe a design for a state machine that could run. The graphical notation that represents the model could be considered a state chart.

I think the question you quote is actually confused and confusing. Harel's paper from 1984 referred to Mealy and Moore formalism as "conventional", but that word might apply to Harel's work as well now. The term "state chart" probably refers to Harel or UML, which can be mapped into Mealy or Moore state machines. I would answer the question by enumerating the differences, nonetheless.

Jim L.
  • 5,273
  • 3
  • 14
  • 44
0

(Maybe too late) A maybe good hint to answer the question would be the groundwork on the statecharts itself - the paper from David Harel "STATECHARTS: A VISUAL FORMALISM FOR COMPLEX SYSTEMS" from 1984.

Namely:

A good state/event approach should also cater naturally for more general and flexible statements, such as

(1) “in all airborne states, when yellow handle is pulled seat will be ejected”,

(2) “gearbox change of state is independent of braking system”,

(3) “when selection button is pressed enter selected mode”,

(4) “display-mode consists of time-display, date-display and stopwatch-display”.

Clause (1) calls for the ability to cluster states into a superstate, (2) introduces independence, or orthogonality, (3) hints at the need for more general transitions than the single event-labelled arrow, and (4) captures the refinement of states.

HTH

Alexander Mihailov
  • 655
  • 1
  • 8
  • 15
0

See my full answer at https://stackoverflow.com/a/67067188/2183503, but In a nutshell, statecharts are to state transition diagrams what modular decomposition and abstraction are to monolithic code

HTH (it helped me understand the differences).

kotpal
  • 347
  • 4
  • 11