0

I am using Rational Rhapsody for project development. I am using a state machine for state (screen) transitions, which can be done using a switch as well. I want to know what are advantages of state machine in Rational Rhapsody when compared to switch statements.

Melebius
  • 6,183
  • 4
  • 39
  • 52
arayan
  • 21
  • 5
  • 2
    Last time I used a state machine, it was done with a switch case construct. Your tags are contradicting. You can use either C or C++ but not both at the same time. – Gerhardh Apr 04 '18 at 08:26
  • Ya it is either c or c++,I am using c++ – arayan Apr 04 '18 at 08:27
  • 1
    Then please do not add unrelated language tags. – Gerhardh Apr 04 '18 at 08:28
  • 1
    @Gerhardh what the problem with usage of C and C++ simultaneously? They are perfectly compatible. – Anton Malyshev Apr 04 '18 at 08:32
  • 1
    They are different languages with different rules. The fact that some part of syntax and semantics is similar does not make them same language. Lots of them are very **non**-compatible. – Gerhardh Apr 04 '18 at 08:34
  • @AntonMalyshev not at all. You can construct a usable subset of both languages to make polyglots with, but that subset is both lame C and awful C++. – Quentin Apr 04 '18 at 08:35
  • lol guys, you are so religious, that compatibility makes your OS work for example – Anton Malyshev Apr 04 '18 at 08:37
  • 2
    @AntonMalyshev you can interoperate C and C++ binaries via `extern "C"`. That is *not* using both simultaneously. In any case, a vague question that does not even settle on a language cannot produce a good result. – Quentin Apr 04 '18 at 08:40
  • Related: https://stackoverflow.com/questions/1371460/state-machines-tutorials or https://stackoverflow.com/questions/14676709/c-code-for-state-machine – Bob__ Apr 04 '18 at 08:55
  • A state machine can also be implemented with switch. So the question is fully off topic. One is a design question and one is implementation detail. So how can it be compared are argued? – Klaus Apr 04 '18 at 08:55

1 Answers1

1

Your question is a little off-mark :

A state machine is a "concept", while a switch-case is a possible implementation of a state machine.

It's like saying "can we do imperative programmation in C++ ?". Imperative programmation is the concept (paradigme here), and it's possible to do it in C++.

You can implement state machine by switch-case, array, linked list .... It's up to you to know if you really need a state machine and how to implement it.

Tom's
  • 2,448
  • 10
  • 22