Slashdot Mirror


Practical Statecharts in C/C++

Reader JonKaye contributed this review of Reviewing Practical Statecharts in C/C++. He writes "Since I am not from the embedded system world, I was a bit apprehensive about approaching this book. While I can see that author Miro Samek has a directed target for his audience, I strongly feel that this book is a 'must read' for technical developers in all areas who want to improve their program design abilities or developers who want to understand the philosophy, use, and implementation of statecharts intimately." Read on for the rest. Practical Statecharts in C/C++: Quantum Programming for Embedded Systems author Miro Samek pages 389 publisher CMP Books rating 10/10 reviewer Jonathan Kaye ISBN 1578201101 summary Practical and methodologically sound approach to improving software design using statecharts

As the title indicates, this book brings the topic of statecharts from the realm of expensive design tools to the practical realm, illustrating its points with full examples and extensive commentary.

Essentially Samek postulates that the slow adoption by developers of best practices by statechart design is due to lack of understanding of the fundamental nature of statecharts and how it is perceived as requiring expensive tools to use well. Samek insightfully discusses how statecharts as a best practice embody "behavioral inheritance" as a fundamental design concept that stands as a peer alongside the conventional pillars of object-oriented programming, namely inheritance, encapsulation, and polymorphism.

The book is very technical and written in an academic style, with ample references to original sources as well as detailed code reviews and many reader exercises. I would caution anyone from approaching this book as a quick or light read. For me, it took a seriousness and good understanding of C and C++ to follow Samek's examples and achieve the "a-ha", which was always worth it in the end. The book contains full, working code to incorporate statecharts into my own work, implemented both in C and C++.

The two basic parts of the text are (1) an explanation of statecharts and their methodological implications, and (2) a description of how to apply statecharts as a data structure in real applications, namely embedded as control strategies for "active objects." In several places in the text, Samek makes an analogy between statechart (and active object) semantics and quantum mechanics. This parallel was an interesting philosophical argument, but didn't add much for me in terms of accepting his "quantum framework" as a best practice -- I was sold by his methodological arguments he had presented already.

Speaking from experience in writing a book about using statecharts to build simulations (www.FlashSim.com), I can say Samek is a visionary who extended my perception of statecharts several steps. I know I will be quoting from it and referring to it in my work to come. This book has earned a prominent place on my bookshelf, and I would heartily recommend it to any other developer who wants to create correct, verifiable, scaleable, and solid designs (which should be ALL developers!)

You can purchase Reviewing Practical Statecharts in C/C++ from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

121 comments

  1. Re:C and C++ by olethrosdc · · Score: 1, Informative

    It is easy enough to use a standard library that helps you maintain such buffers/stacks/queues. No need to mess around with standard c arrays.

    --

    I miss my rubber keyboard.(Homepage)

  2. currently reading it by Tangurena · · Score: 4, Informative
    I have not really seen where the word quantum comes in, except as a buzzword. Since I have been looking for a decent, expandable, well written state machine, I picked this book. Perhaps some code bigots will criticize the code, but for my uses, it is good enough. I am tired of having to re-invent the wheel everytime I change employers.

    Most other programmers I meet in the workplace have a hard time understanding state machines. All of those programmers are self taught or picked up "learn programming in 21 days" type of books.

    I recommend this book.

    1. Re:currently reading it by jpmorgan · · Score: 1

      C/C++ just aren't good languages for implementing state machines in. Languages with support for full coroutines (like uC++) make implementing state machines practically trivial.

    2. Re:currently reading it by Simon+Tatham · · Score: 1

      So what's wrong with doing coroutines in C? :-)

  3. Zing .... by binaryDigit · · Score: 2, Interesting

    That's the sound of a topic that went zooming over the heads of most /.'ers (me included). It would have been quite nice of the author to include some links that describe what a statechart is and why a C++ programmer should care. It might be one of those things where the book is geared towards those who already know, but it would still be good so those who don't could get some background.

    I know, I know, you can just google it yourself. But why have hundreds of people searching for exactly the same thing when one person could save a lot of people some time.

    1. Re:Zing .... by broody · · Score: 5, Informative

      State Charts are one of the nine UML diagrams. There are some tutorials here.

      --
      ~~ What's stopping you?
    2. Re:Zing .... by Anonymous Coward · · Score: 1, Insightful

      Most objects, C++ or otherwise, are stateful (have local data) and have operations or methods which are basically state transition mechanisms. That is, they are basically finite state machines. So it would be very sad indeed if the concept of a state machine or state chart should be "over the heads of most /.'ers". When working with object, the only choice is between a well-designed state machine and an accidentally-designed state machine.

    3. Re:Zing .... by 680x0 · · Score: 1
      I gave a lecture on state machines once, and my notes are still online. I'm not sure that enough of the lecture is there (just the outline) to educate someone, but it's a start, and has some code examples.

      And, these are really informal "state machine diagrams", so I can't say whether they conform to UML "statechart" standards (I don't think UML was around in the mid 80's when I was learning this stuff).

    4. Re:Zing .... by ClosedSource · · Score: 1

      Well, a lot depends on the granularity of the "states" you're talking about. It's generally impractical to design a fine-grained state machine for anything but the simplest system because of state explosion.

      Even if the result can be thought of as a state machine, it's often better not to model it as one.

  4. Re:C and C++ by Anonymous Coward · · Score: 0

    uh, this is realtime, baby. screw the unecessary overhead of STL. i'm a big boy and can handle native c arrays just fine.

  5. what ever happened to Zone Logic? by e4liberty · · Score: 4, Interesting

    Zone Logic is a nice combination of state charts and autononmous agent design. It was used in the 80s and early 90s for industrial automation, and was particularly good at recovery from hardware failures.

    Real-time systems depend on sensors to report the state of the outside world. These sensors often fail, putting the system in an illogical state. Zone Logic offered a nice structured way to deal with this.

    R. Roberts. Zone Logic: A Unique Method of Practical Artificial Intelligence. Radnor, PA, Compute! Books, 1989. citeseer

    1. Re:what ever happened to Zone Logic? by Anonymous Coward · · Score: 0

      I didn't know anyone else knew about Zone Logic. I believe that the company that developed it (Lamb Technicon) sold that division to one of their suppliers (name escapes me).

      The supplier killed it in order to push another methodology.

      I understand that the developers loved it, as it was a huge advance from the ladder logic that they typically used. But the end-users didn't understand it.

  6. What I use... by guido1 · · Score: 3, Informative

    I use Bruce Powel Douglass' Real-Time UML, Second Edition, Developing Efficient Objects for Embedded Systems .

    It only has 1 chapter on UML statecharts, but after reading through it, I was able to describe in 1 diagram LCD behavior that used to take ~20 weakly worded requirements. (Shall do this, except when this, etc...)

    If you're having trouble being explicit and clear in requirements, I would highly recommend looking at statecharts. (Picture speaks a thousand words, eh?)

  7. Re:C and C++ by Anonymous Coward · · Score: 1, Insightful

    C and C++ are not going away. They will never go away. There will always be a need for that sweet spot that gives the power of assembly and the readability of a HLL. And sorry Java just doesn't cut it.

  8. BUY THIS BOOK NOW! by Anonymous Coward · · Score: 1, Funny

    State charts are teh next big thing (or at least, next big buzzword). I do a lot of consulting, and I've seen "Object Oriented" supplanted by "Unifide Model" supplanted by "XML". Well, Statecharts are likely to be the next buzzword. Sure, they're overrated, and will be forgotten ina couple years, but if you're on the job market, you need to know the lingo.

    1. Re:BUY THIS BOOK NOW! by Anonymous Coward · · Score: 0

      State charts have been around for a long time. Assembly programmers have been using state charts for decades. Plenty of ways to implement them and once you understand them you realize how powerful they are. Very robust in nature and suited well for embedded designs.

  9. A question on the book... by Anonymous Coward · · Score: 0

    For those that have read it or are reading it.

    Does it address programming general/arbitrary FSMs or managing Object state al-la UML state charts?

    Thanks.

    1. Re:A question on the book... by JonKaye · · Score: 1

      The book sketches the process and gives C and C++ code for programming both linear finite state machines (what we typically think of as FSM's), and the more powerful hierarchical state machines (aka, statecharts). It doesn't get into some of the nuances of UML statecharts, but in my opinion, it addresses a very large percentage of them (maybe 80-90% or more) and you can add the ones you need with the basis provided. -jonathan

      --
      Jonathan Kaye, PhD
      http://www.amethyst-research.com
      http://www.FlashSim.com
  10. gee, thanks by joenobody · · Score: 5, Informative
    Would it have killed the author to mention what a statechart is?

    Ah, well, google to the rescue: here's good example of a statechart.

    --

    1. Re:gee, thanks by jjjefff · · Score: 3, Informative

      Here's a longer overview... Could only find it in Google's cache.

    2. Re:gee, thanks by Anonymous Coward · · Score: 0
    3. Re:gee, thanks by pohl · · Score: 1

      Ah, so "StateChart diagrams" are just what the softies are calling "state diagrams" or "state machines" these days. Look mom, I can write a switch/case statement and diagram it in UML. Yawn.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    4. Re:gee, thanks by Anonymous Coward · · Score: 0

      Ah, well, google to the rescue: here's good example [dotnetcoders.com] of a statechart.

      Is it just me, or does this diagram look just like a flowchart?

    5. Re:gee, thanks by Danse · · Score: 1

      It only looks like a flowchart to the untrained and horribly ignorant eye. :)

      --
      It's not enough to bash in heads, you've got to bash in minds. - Captain Hammer
  11. Re:C and C++ by Anonymous Coward · · Score: 0

    A good knowledge of C ... blablabla. No need to mess around with C++.

  12. The UML crowd discovers finite state automata by Animats · · Score: 4, Insightful
    ...and act like they invented them.

    State machines aren't that complicated. The UML people are just burying them under a mess of jargon. This is probably not helpful.

    UML is a reasonable idea that's turning into a management fad and is being used to sell overpriced tools. Such fads come around from time to time. Anyone remember decision logic tables? "Bubtangles?" The Kepner-Tregoe method? "Business Objects?"

    1. Re:The UML crowd discovers finite state automata by DogIsMyCoprocessor · · Score: 1
      There's no such claim by the "UML crowd". All statecharts are is a better notation for documenting an FSM than a traditional state diagram. A statechart allows you to naturally decompose the FSM into simpler parts, which scales better (in terms of diagram size) for large FSMs. There is also some other nice "diagrammatic sugar" such as symbols for the default entry point into a sub-system and so on.

      Here's a book that presents a good case for using statecharts in one particular problem domain. Like any tool, using them for everything would be a mistake. But I think a real advocate of UML wouldn't say you need to make class diagrams of everything, either.

      --

      "And this is my boy, Sherman. Speak, Sherman." "Hello." "Good boy."

    2. Re:The UML crowd discovers finite state automata by Fnkmaster · · Score: 1

      As I see it, this looks like the kind of thing that people who don't have a formal CS background might "discover". I mean, I thought it was basically obvious to use FSA diagramming to document state transitions in software systems. I've been doing this for years, without the guidance of a UML "statechart" system. The only benefit of these things is providing examples of "real world" usage and how a particular problem domain was mapped into a FSA, which might make it more obvious how to use the formalism when faced with a particular problem.

    3. Re:The UML crowd discovers finite state automata by Anonymous Coward · · Score: 0

      I think what happened is formal CS ignored state based programming in favour of new fangled methodologies like top down programming. It certainly disappeared long before the fetish for OO started.

      A real pity, I learned state based programming and the use of state diagrams before anything else over 25 years ago. Its always been useful and always produced good results. Yet my CS degree course never mentioned it. Maybe it got swept away when flowcharts went out of fashion, maybe the academics never bothered with it. Doubt we'll ever find out.

    4. Re:The UML crowd discovers finite state automata by Anonymous Coward · · Score: 0

      A black dot is your idea of innovative naturally decomposed better diagrammatic sugar symbol notation for the simple "start here" label that ever kid who's ever solved a maze knows? Thank Xenu for UML!

      At least I didn't feel a need to use bold in random words and phrases throughout my post to emphasize my point. everything

      everything

    5. Re:The UML crowd discovers finite state automata by Bodrius · · Score: 1

      "...and act like they invented them."

      They do?

      Funny, every UML book where i have read something about statecharts mentions they're just state diagrams for finite automata.

      "State machines aren't that complicated. The UML people are just burying them under a mess of jargon."

      They are?

      It seems to me this is necessary, as it is in other UMLized diagrams, in order to generalize it so it can be useful out of the context they got it from in the first place. It's part of the "universalizing" process.

      For example, class diagrams are much more complicated, and have more jargon, than the ER diagrams they got them from, but are also more flexible and embrace a wider context.

      It's not like Finite Automata are not full of their own jargon, which tends to be technical and/or academic and much more complicated to understand for someone without the CS background.

      "UML is a reasonable idea that's turning into a management fad and is being used to sell overpriced tools."

      Quite true, but I don't think this has much to do with the "UML crowd". I think it has more to do with managers who don't know what UML is exactly, but are wooed by promises of code-generation, productivity increases, etc.

      The "UML crowd" love UML but know what it is: a STANDARD notation for design and modelling diagrams.

      Expensive or inexpensive tools are actually quite good these days, but until relatively recently I did my UML diagrams in a pre-MS version of Visio (1998) using standard polygons, stick figures and connectors. I could very well have used a cheaper diagraming tool, Paint, or do it by hand.

      The diagrams were still very useful.

      --
      Freedom is the freedom to say 2+2=4, everything else follows...
    6. Re:The UML crowd discovers finite state automata by DogIsMyCoprocessor · · Score: 1

      Thanks for the flame. It made me laugh ... really.

      --

      "And this is my boy, Sherman. Speak, Sherman." "Hello." "Good boy."

    7. Re:The UML crowd discovers finite state automata by Animats · · Score: 1

      Have the "statecharts" people developed a way to provide something subroutine-like for finite state machines? A big problem with finite-state machines tends to be a need for multiple copies of very similar subgraphs to handle similar situations.

    8. Re:The UML crowd discovers finite state automata by JonKaye · · Score: 1
      As I see it, this looks like the kind of thing that people who don't have a formal CS background might "discover". I mean, I thought it was basically obvious to use FSA diagramming to document state transitions in software systems...

      Excuse me, hardgrok, but you might say my PhD in Computer Science is kind of a "formal CS background." I learned about FSA in my algorithms class both as an undergrad and grad student, and I can clearly see that statecharts are not the same thing by any means. I find that people who make the comments like you made really haven't taken any time to read about statecharts, or perhaps have seen them in expensive tools and dismissed them as just something else to learn and not worthwhile. A lot of times, people dismiss them because they have not seen good examples of their use.

      I'd strongly suggest you read Ian Horrocks' book about using statecharts for user interface design (Constructing the User Interface with Statecharts), or Miro Samek's book on embedded systems, or my book on simulation construction with statecharts ("Flash MX for Interactive Simulation"). You will see that much traditional software, made by people with more than enough CS background to go around, in many cases still suffers from design problems. Horrocks has a great example of problems with the Visual Basic calculator that comes with Windows, and Samek has a great example (Therac-25) of a therapeutic medical device that killed people because of programming design flaws.

      If you're looking for something on the web to preview, I would suggest reading David Harel's original 1987 paper that started things out (http://www.wisdom.weizmann.ac.il/%7Eharel/SCANNED .PAPERS/Statecharts.pdf), or you can look at some references I have from my web site (http://www.flashsim.com/flash_resources-uml.html# state).

      -jonathan

      --
      Jonathan Kaye, PhD
      http://www.amethyst-research.com
      http://www.FlashSim.com
    9. Re:The UML crowd discovers finite state automata by Fnkmaster · · Score: 1
      Well, I appreciate your reply, but there is no need for you to be defensive - I wasn't attacking you on an ad hominem basis, merely hypothesizing that sometimes the industry community gets hot and bothered over ideas that are old hat in academic computer science. After skimming David Harel's paper, I agree that there are some additions and extensions to the statechart formalism vs. traditional FSA diagrams. I was never denying that people had proposed such additions nor that they could be useful.


      Rather, I was pointing out that without ever reading these formalisms, many of us have similarly used hierarchical, divided or otherwise "non formal" state diagrams to describe either parts of systems or entire systems, where appropriate. I am not questioning the use of such diagrams in system design, since I admitted I have used such tools to communicate system design specifications. Additionally, the fact that software exists that is poorly designed (something nobody denies) does not serve as an effective argument that "statecharts" are substantively different from FSA diagrams. Much software out there in the world is NOT designed by people with sufficient theoretical CS background, or practical engineering experience.


      I am not sure about modeling UIs as state machines, but I will reserve my comments as I haven't seen the book.


      My point still stands: this is a modest recasting of an existing formalism into a more "relaxed" and practical form that communicates several pieces of information simultaneously. It's nothing I would consider totally new or innovative. It may be useful as a technique for practical system design, but the primary purpose of reading these books is probably to see examples of mapping particular problems to a state machine model - there's nothing magical about a "statechart" that you need to read a book to understand.

    10. Re:The UML crowd discovers finite state automata by JonKaye · · Score: 1
      I wasn't attacking you on an ad hominem basis, merely hypothesizing that sometimes the industry community gets hot and bothered over ideas that are old hat in academic computer science


      Sorry -- I didn't mean to go off on you or anyone in particular, and I understood your comments in the non-personal context.

      I am no 'statechart-does-everything' zealot, but I've found even among CS educated people, that they tend to dismiss things because the value is not immediately obvious, especially as I infer from you, when there aren't some good examples to drive the points home. In that regard, both Horrocks and Samek show some good real world examples (Horrocks - design flaws in the Microsoft Windows calculator, Samek - the Therac-25 medical device that killed people as a result of design flaws in the capturing of machine state).

      I agree with you completely that there is nothing magical about a statechart. I think Samek's point is exactly that -- too often, statecharts are seen in association with expensive tools, and so the message is that you need an expensive tool to work with them. Samek argues that statecharts will have their greatest value as a developer-empowering design methodology, not the output of a code generation program for the high-level user. I think the tool companies too often try to sell it to high-level people rather than get down and dirty and explain how statecharts can help the low-level developers.


      I also agree with you that this is not new or innovative -- it has been around for almost 20 years! Still, however, many developers haven't heard about them or have dismissed them outright because of lack of knowledge. Yet programs today routinely are HUGE and have life cycles easily of years if not decades. With big pressures on developers to meet deadlines, less emphasis is placed on design for longevity, and future developers (and users) will suffer.

      -jonathan

      --
      Jonathan Kaye, PhD
      http://www.amethyst-research.com
      http://www.FlashSim.com
    11. Re:The UML crowd discovers finite state automata by ralphbecket · · Score: 1

      Yes: check out recursive transition networks.

    12. Re:The UML crowd discovers finite state automata by Anonymous Coward · · Score: 0

      This is kind of the problem -- 99 per cent of CS students see FSMs in their compiler class and fail to see how generally applicable and useful the concept is.

  13. Re:C and C++ by Curien · · Score: 1

    What overhead? Perform some tests with decent compilers. You might be surprised.

    And he never said STL. He said *a* standard library. But anyway...

    --
    It's always a long day... 86400 doesn't fit into a short.
  14. State charts and C by mao+che+minh · · Score: 2, Funny
    I decided to read between the lines:

    "While I can see that author Miro Samek has a directed target for his audience, I strongly feel that this book is a 'must read' for technical developers that wish to eliminate their chances at successfully mating within the next three to four days. In most cases, the knowledge gleaned from this book will also allow the reader to avoid sexual intercourse indefinately (excluding mating rituals that involve the transfer of monetary units first)."

  15. Ok, state machines by pclminion · · Score: 5, Informative
    I wss a little confused by the term "statechart," but it turns out he's talking about finite state machines. I guess he figured one more new buzzword wouldn't kill anybody...

    A state machine is a way of representing a computational task. The machine or program can be in precisely one of a number of possible states at a given time. Different kinds of events cause the system to move from one state to another state (called a transition). Each transition can have an associated side effect. Therefore, the model of computation is:

    1. read input
    2. decide which state to move to based on input and current state
    3. execute transition action
    4. actually move to the new state
    5. return to step 1
    State machines are theoretically limited in the kinds of input sequences they can process. As it turns out, a state machine can only process inputs which can be described by regular expressions. However, it is possible to "augment" a state machine to extend its power. If you do this by adding a data stack, you have produced what is called a "pushdown automaton" and this gives you a great deal of power. But that is a departure from a pure "CS" FSM.

    The FSM is sort of the bottom rung of the computational ladder. FSMs can process regular languages (i.e. the languages describable by regular expressions). PDAs can process context-free languages (like most programming languages). Even more powerful than a PDA is a Turing machine, the theoretical "ultimate" model of a computing machine.

    It might seem odd to think of the input events to the program as comprising sentences in some "language," but it makes sense when you consider it. Input events have an inherent structure to them, and this structure can often be described in the form of a regular language. In these situations, using an FSM model of the code is very natural since the code is directly, structurally related to the events it is processing.

    Ok, there's your dose of CS for the day.

    1. Re:Ok, state machines by joshwalker · · Score: 1

      When I heard the author speak at a meeting of the ACCU recently, he described statecharts somewhat differently from the basic FSMs I knew.

      Basically, statecharts allow some extensions to FSM: nested states, init/entry/exit actions for states, and probably some others. Apparently these are all defined in UML.

      The author's basic approach is to represent the state as a pointer-to-member-function. Except that he's working on embedded systems, which means he uses C, which means he hacks his own OO in C. I must admit that this distracted somewhat from his main point.

    2. Re:Ok, state machines by Anonymous Coward · · Score: 0

      I took a class about a year ago at my part-time university about Digital Systems as I am studying Computer Engineering (sort of a cross-disciplined BS degree between EE and CS, with an emphasis on EE). We did state diagrams towards the end of the class, and while difficult to grab a hold of the concept initially, I saw the potential to use state diagrams in nearly every computer application, as you could literally design any system to be "nearly" fail-proof before even writing any code.

      I guess that's why they say EE's can do pretty much any job they want to. ;)

    3. Re:Ok, state machines by Anonymous Coward · · Score: 0
      In engineering, we learn that there are two types of state machines.
      • One type has actions that occur in response to a transition (e.g. state0->state2 can have a different effect than state1->state2).
      • The other type has actions that are constant for an given state (i.e. entering a given has the same effect regardless of where you came from).

      There is only a subtle difference between the two types of machines, since each can be converted to the other. In general, the former models branching software programs and the latter is better for sequential logic and hardware.

      Ok, there's your dose of EE for the day.

    4. Re:Ok, state machines by urbi · · Score: 1
      He's not talking about finite state machines. Statecharts are much more. For example:
      • You have nesting: it is easy to jump out of a sub-statechart. No need to draw arrows from all the states inside to the outside world.
      • You have parallelism: if a statechart is subdivided with dashed lines (or whatever the fashionable notation for this is now), you have two (or more) control flows.
      Statecharts are actually used to fully describe beasts like factory process control systems (the tools then generate C code). They are not simple toys like FSMs.
    5. Re:Ok, state machines by pclminion · · Score: 2, Informative
      You have nesting: it is easy to jump out of a sub-statechart.

      Without knowing more detail, I can only speculate here but from this statement, it appears this allows you to "call" another FSM from a particular state. Ok, now you have a PDA, the next step up from a FSM.

      You have parallelism: if a statechart is subdivided with dashed lines (or whatever the fashionable notation for this is now), you have two (or more) control flows.

      This is known as nondeterminism in computer science. Any nondeterministic machine can be converted to a deterministic one (removing the virtual parallelism). It doesn't add any theoretical power, but it definitely makes it easier to design the machine.

      They are not simple toys like FSMs.

      FSMs are simple, but they aren't toys.

    6. Re:Ok, state machines by Wesley+Everest · · Score: 1
      So, it sounds like hierarchical finite state machines (HFSMs). I'm not dissing on statecharts, btw -- just from all the descriptions so far, it sounds like "statechart" is a technical term used by one crowd to refer to what my crowd usually refers to as HFSMs.

      I'd be curious to hear if I'm mistaken and there's more to it than that.

    7. Re:Ok, state machines by egoots · · Score: 1

      I wss a little confused by the term "statechart," but it turns out he's talking about finite state machines

      The term statechart has been in the Comp Sci and then OO literature for a number of years, it was later adopted by the UML group. IIRC they often refer to David Harel as a source of much of the background on the concepts.

      A quick google search shows the following reference:

      • D. Harel. Statecharts: A Visual Formalism for Complex Systems. Science of Computer Programming, July 1987, pp. 231-274
    8. Re:Ok, state machines by marhar · · Score: 1

      Try again. It's not a PDA. Here's the original TR by Harel, who developed the concept:

      Statecharts.pdf

    9. Re:Ok, state machines by Old+Wolf · · Score: 1

      This might be useful for game programming. Instead of creating dozens of event handlers for my gui-based state game, and having lots of enums and switch statements everywhere and really getting lost in spaghetti, I could make one of these statecharts and code a FSM for it.

      Is there a good visual representation of states that is more efficient than listing them out in words? (sort of like flowcharts are easier to look at than "IF (blah) GOTO (blah) ELSE (blah)")

  16. Huh, you finally figured it out? by cybermace5 · · Score: 4, Insightful

    And it took an embedded systems developer to bring it to your attention.

    It's not new. We've been doing state diagrams over here in Engineerland for decades.

    --
    ...
    1. Re:Huh, you finally figured it out? by Anonymous Coward · · Score: 0

      A soft drink vending machine is a finite state machine. These youngin's probably think you need a microprocessor to calculate change!

    2. Re:Huh, you finally figured it out? by cybermace5 · · Score: 1

      Not to mention those slick little logic controllers that used compressed air lines and air-controllable valves.

      --
      ...
    3. Re:Huh, you finally figured it out? by bmurray · · Score: 1

      And we in the Mathamatical realm have been doing it since.....hey didn't we come up with it in the first place?

    4. Re:Huh, you finally figured it out? by Anonymous Coward · · Score: 0

      And we in the...realm of language came up with "mathematical," which we actually know how to spell correctly.

  17. A little background information... by MmmmAqua · · Score: 2, Informative
    --
    Arr! The laws of physics be a harsh mistress!
  18. Statecharts Driven by jetkust · · Score: 2, Insightful

    I once had to use an authoring tool (Rapid CBT), priced in the thousands of dollars, which was completely driven by statecharts. In my opinion, the statecharts offered no advantage at in the development as most of the logic needed wasn't suitable for statecharts. My guess is that statecharts are an easy way to make a visual representation of what is happening in the code, but is restrictive to the coding itself.

    1. Re:Statecharts Driven by threadsafe_r · · Score: 1

      hmmm... my experience has been it depends on several factors (problem/solution/environment, etc.) that might govern "advantage". e.g. Kabira's Design Center utilizes a really sweet plugin to Rose - almost 100% driven by UML/statecharts. I can't imagine a better tool for deriving solutions for the types of problems its best suited to solve. But as you point these tools are costly $$$!.

    2. Re:Statecharts Driven by JonKaye · · Score: 1
      I've seen Rapid, and it is a very good tool for some purposes. However, the point of Samek's book is that the concept behind statecharts is valuable as a way to design and program better. Too often, statecharts are seen in association with expensive tools (like Rapid), and the vendor doesn't do a good job of teaching the thought process for designing in this way. Also, because the coding is hidden behind the visual tool, the developer doesn't feel comfortable making changes to the code even when it is possible (this is the reluctance you describe).

      The solution is to explain the concepts behind statecharts better so that the developer is in control. In other words, to empower the developer, not make a tool that dumbs things down. Miro Samek (and Ian Horrocks, in his book, Constructing the User Interface with Statecharts, and me, in mine - Flash MX for Interactive Simulation) teaches the concepts so that you see the meaning and not confuse it as requiring some visual (and expensive) tool.

      -jonathan

      --
      Jonathan Kaye, PhD
      http://www.amethyst-research.com
      http://www.FlashSim.com
  19. Real world examples. by dsplat · · Score: 3, Interesting
    It would have been quite nice of the author to include some links that describe what a statechart is and why a C++ programmer should care.


    I learned about state diagrams in college years ago. The examples that we used at the time were all the sorts of things that could be done as stand-alone projects. They typically involved parsing strings that had to match a description given by a state diagram. If you are building a lexical scanner by hand or a regular expression library, it's good stuff to know. However, I wondered how often I'd see it in the real world.

    Well folks, this can be real world stuff if you apply it. It's all about retaining a state that summarizes inputs that you have seen so far. This is about communication between autonomous devices (or with a user). If nothing else, state information is useful in retaining position within a set of search results when a user is paging through them. It can be used in the session layer of a communication protocol to track handshaking. If you have to asynchronously do two things concurrently within your program, unless each of them involves completely separate transactions that are completely atomic, one or both can be modelled as state machines.

    If you write GUI code where you have buttons being toggled, check boxes checked or fields filled, you have a state machine, whether you coded it or not.

    If you are writing embedded systems, you don't need me to tell you that you are maintaining real time state information about the devices you are talking to.
    --
    The net will not be what we demand, but what we make it. Build it well.
  20. anyone else first read that as... by Anonymous Coward · · Score: 0

    submitted by JonKatz, and then promptly skip down to the next story?

  21. Doom using the zombie trick....Re:Zing .... by mrmeval · · Score: 2, Interesting

    If you've ever used one of the source ports that allow more triggerable actions and used a 'zombie doll' you've designed a state machine.

    For instance. When the player crosses a line I want the following to happen. I don't really know state semantics so it's in english which for a programmer is very poor. This can be as complex as you want, this is just a simple one:

    Set up some moving floors that will carry an object (zombie doll).

    Player crosses line.
    Open a door and release zombie doll.
    Zombie doll 1 moves, crosses a line and turns up the lighting.
    Zombie doll 1 moves crosses a line and opens trap door releasing monsters at player.
    Zombie doll 1 moves crosses a line and opens another door releasing Zombie doll 2
    Zombie doll 2 moves crosses line opens exit for player.
    Zombie doll 1 stops.
    Zombie doll 2 moves crosses a line drops floor player may be on.
    Zombie doll 2 moves crosses line which turns pit floor into lava.
    Zombie doll 2 moves.
    Zombie doll 2 moves.
    Zombie doll 2 crosses line and opens an exit for the player.
    Zombie doll 2 stops.

    A friend rendered a bloated complex microprocessor design into a state machine he placed on an eprom.

    The eprom was clocked and some other chips added to step it through a rather complex routine. It could take input, it could 'make decisions' based on that input, all of it was encoded on the eeprom.

    It required no microprocessor, minimal support hardware ect etc. Just a clock, an eprom, some logic chips and someone who knew state machines.

    It was 1000 times less expensive than the buggy, non-working microprocessor design.

    All he had to do was see what the customer wanted to do and purpose program it for that task. If it needed reporgramming, burn another eprom.

    --
    I'd go on a Vegan diet but the delivery time from Vega is too long. --brownkitty
    1. Re:Doom using the zombie trick....Re:Zing .... by binaryDigit · · Score: 1

      Actually this is a good example of why I made my comment. If statecharts are simply a way of representing state machines (which makes sense, but I was wondering if there was more to it to warrant a "new" book on a old subject) then that mere mention would have clarified things significantly. A great deal many programmers are familiar with state machines that have no clue about the UML statechart.

  22. Re: Kepner Tregoe by kwpapke · · Score: 1

    > Anyone remember decision logic tables? > "Bubtangles?" The Kepner-Tregoe method? I remember Kepner-Tregoe, and apparently am not alone: http://www.kepner-tregoe.com/ I also still use Problem and Decision analysis.

  23. All programs are state machines. by Anonymous Coward · · Score: 0

    Though I suppose the you could write on that doesn't take input and doesn't produce output; but why bother?

  24. bumsword of the month - certifiably by mmphosis · · Score: 2, Interesting

    ... methinks SlashDot may be spammed by m$monkeys. Many of my Google searches on this topic ended me up at the msdev site.I resist temptation to drop US$15000 to be m$certified.

    State machines, statecharts, all seems a tad modal to me. State, to me, is simply a piece of information and calling it "state" and giving it this whole modal metaphor simply confuses. I hear a FUDding sound

    progging by example, examples, lots of examples oh, and we're "modelling" here we don't actually need to do any coding

    A button object definition
    (aka a class) with various interface methods (messages/questions you can command/ask of this object) that I choose to dangle off of it:
    Is button down
    Is button up

    Buried underneath/within/externally/remotely of this object somewhere, that no one needs to know about, is some storage that somehow indicates whether the button is currently "up" or "down." I guess some might call this the "state" of the button.

    clear as mud

  25. Re:C and C++ by Anonymous Coward · · Score: 0

    He's talking about the overhead you see if you actually perform the tests on STL and compare to a custom implementation. It's there, but you have to be slightly insane to care about it, in most circumstances. Actually, you'd have to be slightly insane to use C++ in most circumstances, if not for the fact that co-operating with the rest of the world is easier if you share their insanity.

  26. This is distrubing... by fireboy1919 · · Score: 1

    Quantum...my guess is that they're referring to the quanta of an embedded system - which would be states.

    I seem to recall that state machines were the first thing that I learned when I started learning about computer architecture. They are, after all, the basis. What I find disturbing is that programmers that you meet in the workplace have a hard time understanding state machines and they're still in the workplace.

    Isn't that a like knowing how for loops work? Or how to do recursion? It's a basic fundamental concept. This is even more true for embedded systems, where many (machine based) optimization techniques involve using a strict Meely or Moore implementation of a state machine (I'm thinking right now about how much better it works if you program using one of these models when writing in VHDL for an FPGA).

    --
    Mod me down and I will become more powerful than you can possibly imagine!
  27. I�ve been using statecharts since using FORTH by fwarren · · Score: 1
    FSM's are often used in FORTH. Since it is easy to create an array of functions to be called.

    Create a buffer, fill it with input and call the function for the inital "state", which processes the input and passes it off to the next state in the array, till you hit a function which "finishes" the transformation of the input string.

    --
    vi + /etc over regedit any day of the week.
    1. Re:I�ve been using statecharts since using FORTH by Anonymous Coward · · Score: 0

      For all the elitists, Samek's book describes the Hierarchical State Machine (not just the Finite State Machine you used in FORTH), and provides a C++ implementation he calls the Quantum Framework.

      Check out Samek's website where you can download articles, tutorials, and the framework impelementation (in many other languages).

  28. Reviewed in Dr. Dobb's Journal by Mushy · · Score: 2, Informative

    Ed Nisley had reviewed this in Dr. Dobb's Journal. The review is available here. I had just read the article this morning and was pleasently surprised to see the review here.

  29. Another reason by LinuxInDallas · · Score: 1

    ...to be familiar with state charts is that there are some good tools out there that can generate code straight from a state chart diagram. The implementation from IAR (www.iar.com) even handles real-time designs.

  30. Re:C and C++ by khuber · · Score: 1
    "There will always be a need for that sweet spot that gives the power of assembly and the readability of a HLL".

    I've never seen assembly that's as horrible to read as C++.

    Maybe if you look at the bits in the binary form of machine language, and then poke a pencil in your eye at the same time.

    -Kevin

  31. Re:C and C++ by rokicki · · Score: 1

    I thought it was "all the power and speed of assembly with the readability and abstraction power of assembly".

  32. Re:Ok, state machines, but... by Nyarly · · Score: 2, Informative
    Differences between a statechart and an FSM:

    First and absolutely foremost: an FSM is an adstract concept born of graph theory. A statechart is a diagram of an FSM, which complies to a rigorous specification for what each notation means.

    The statechart spec adds a few semantically trivial notations (i.e. they can be easily translated into standard digraph style FSM), which are nonetheless extremely useful for presenting clear, easy to understand diagrams.

    Most of those additions have been mentioned already (e.g. nesting) but there are also guard conditions (i.e. transition if X except if y), and indications of entrance, presence, and exit behavior. Very handy for describing behavior.

    --
    IP is just rude.
    Is there any torture so subl
  33. well, as a notation it's not bad by Trepidity · · Score: 1

    As a notation for FSA diagramming, statecharts actually are pretty good. They have some handy shorthands that factor out common parts of the state to keep diagrams from blowing up to enormous numbers of states, as would happen if you enumerated all possible states as in a traditional FSA diagram. Sort of a hierarchical way of doing FSA diagramming, which is well-suited to some problems.

  34. FSM's not trivial in C++ by Anonymous Coward · · Score: 0

    When I was still employed, I implemented networking protocols in C++, and that means implementing lots of interacting state machines.

    The simplest way to model messages between the state machines is a function call, but function calls come with a severe penalty: it can be really difficult to know when you can destroy an object. The message that triggered the destruction may have been called from a function that was called from a function that was called from a function belonging to the object to be destroyed.

    The most straightforward trick is to move all interobject function calls to the end of the function leaving only return statements hanging in the air in case the object gets destroyed within the function call. However, that is often impossible to arrange.

    Another possibility is to marshal all interobject messages into a message queue, but that will degrade the performance significantly and still forces you to keep track of dead objects that have messages pending in the queue.

    In practice you are left with error-prone optimizing tricks and flags for pending conditions.

    The whole thing is much easier to manage with languages that have garbage collection built in, although you are again paying a performance penalty.

  35. What Statecharts are by Aron+S-T · · Score: 2, Informative

    As one of the original developers of Statemate, a tool for modelling with Statecharts, I have to step in here. Statecharts are not flow charts nor are they state diagrams. They are an extension of the latter, but they are actually a mathematical language based on temporal logic. As such, Statecharts can be processed to prove or disprove assertions about your design.

    Alsthom Alcatel, for example, used our tool to discover flaws in the high-speed TGF before they started actually building it. They thereby saved millions of dollars in construction retooling costs and probably some lives as well.

    You can find a whole bunch of whitepapers here:

    http://ilogix.com/quick_links/white_papers/index .c fm

    Full disclosure: I still have in a drawer somewhere some stock options in i_logix, which was founded in 1984 but never did go public :)

  36. Additional tools by mzipay · · Score: 1

    The reviewer makes a great point (both philosophically and as a selling point for the book) - the ability to model state is absolutely invaluable when it comes to designing systems that are both effective and efficient.
    My new hammer in the state modelling department is petri nets; I would recommend any developer looking to learn about state modelling investigate petri nets as a supplement and/or replacement for state charts.
    The translation of state chart to petri net (and vice-versa) is fairly straight-forward; petri nets also provide more robust options for modelling concurrency (it is possible to model non-deterministic choices using petri nets). Colored petri nets add the ability to factor time into the model as well.
    There are many petri net tools (of varying usefulness) available for a multitude of OSes; an impressive list can be found here.

  37. Some good readings ... by Anonymous Coward · · Score: 2, Interesting

    Statecharts are not just buzzword ... I think that the comments should treat this topic as effectively as possible. Statecharts are perhaps one of the most useful ways of representing and specifiying system behavior.

    It is very interesting to see Statecharts mentioned on Slashdot. Statecharts are very useful for many reasons. I know that at NASA, in Europe and in the embedded world, generating code from directly from statecharts is very useful in having a very effective way of producing good code such that all the STATES of the system are known.

    Note however that this DOES NOT mean that the code is verified. Things such as deadlocks, livelocks, and unreached states may exist ... but what one can then do is then run a verifier on the statechart, to sort out these niggly bits.

    Another problem that some Statechart autocoders create is that they use a lot of GOTO statements. If you hate GOTOs then you may encounter them a lot with some tools.

    Some good references:

    Statemate - http://www.ilogix.com/products/magnum/index.cfm
    S tateflow - http://www.ilogix.com/products/magnum/index.cfm
    U ppaal - http://www.uppaal.com/
    FREE and looks very good, it is a real time model checker for timed automata.
    Spin - http://www.spinroot.com/spin/whatispin.html
    Also very good ... and quite powerful

    Good reads are some of

    1. The work by Eric Klavins of Caltech
    http://www.cs.caltech.edu/~klavins/pubs.html
    http://www.eecs.umich.edu/gasm/ (Abstract State Machines @ Umich)

    Particularly Eric Klavins work on "Object Oriented State Machines"
    - http://ai.eecs.umich.edu/CNM/Publications/Publishe d_Articles/EmbeddedSystemsArticle.html
    - http://www.embedded.com/story/OEG20020429S0053

    2. Miro Samek's website
    - http://www.quantum-leaps.com/

    3. "The Curiously Recurring Template Pattern"
    - http://www.langer.camelot.de/Articles/Fawcette/Pat ternAlmanac/review.htm

    4. The Boost C++ Metapramming Library (how can one forget Boost?)
    - http://www.mywikinet.com/mpl/paper/mpl_paper.html# example

    5. Gerrard Holzmann's Spin Tool
    http://www.spinroot.com/spin/whatispin.html
    But you should also read Eric Klavin's Propositional Logic Tutorial
    - http://www.cs.caltech.edu/~klavins/lpe/slides/prop ositional.ppt

    6. The work of Nancy Day at the University of British Columbia
    ftp://ftp.cs.ubc.ca/pub/local/statecharts/README

    And many many more

  38. Not New In CS-Land, either by namespan · · Score: 1

    Five years ago, I was working for a non-profit SW firm that produced multimedia educational tools -- helped kids learn to read, do elementary math. Not only was it the most fun sw place I've ever worked (we were supposed to all go see "A Bug's Life" for iddeas, for example) but they actually engineered their software....

    And the tech specs were described with states. Beautiful, simple, clean. Yep. Good stuff.

    --
    Libertarianism is rich wolves and poor sheep playing gambler's ruin for dinner.
  39. Karnaugh maps. not granularity by Anonymous Coward · · Score: 0

    Granularity?

    Karnaugh maps pretty much define the minimal set of states that a machine should have. PERIOD. this is deterministic and does not "depend on granularity". I, too, am disturbed by the lack of basic logic developers have.

    1. Re:Karnaugh maps. not granularity by ClosedSource · · Score: 2, Interesting

      Karnaugh maps were traditionaly used by hardware logic designers to minimize the number of gates required to implement a logical function at the bit level.

      If the system uses a single byte that means you have 256 possible states. If you have two bytes it's 65,536 states and so on. I don't think you want to draw a Karnaugh map for something like Emacs, you won't live long enough.

      That's what I mean by fine-grained state, a single state of the system is defined by the state of all the bits in the system.

      A course-grained state implies a higher level of abstraction. Like in a communications protocol when they say waiting for an Ack is a state.

      So this is what I mean by granularity.

  40. Zing? Odd... by WebCowboy · · Score: 1

    Zing... you can fill a whole book with how to turn a state diagram into essentially:

    switch(statevar) {
    case STATE1:
    outvar = boolfunc1(invar1, invar2...);
    statevar = STATE2;
    break;
    case STATE2:
    outvar = boolfunc2(invar1, invar2...);
    statevar = STATE3;
    break;
    . . .
    }

    Am I missing something here? I'll be first to admit I'm far from a C guru but I fail to see what is groundbreaking about the concept. Of course, I'm an oddball and tend to mentally envision a program as digital circuitry much in the same way someone learning a new language will tend towards mentally translating into english.

    Hmm...I guess those without a background in electrical engineering--particularly digital design--really do get a view from a completely different perspective.

    After a second or two of clue-in time (state CHART == state DIAGRAM == state MACHINE) I was thinking "and the big deal is...?". This concept was covered in an INTRODUCTORY electrical engineering course in my case. We started with "welcome to the world of boolean logic"--working with equations and karnaugh-maps and what not--then went straight onto using those concepts to implement state machines with 74LS... TTL chips stuck in breadboards.

    I guess being that is what I learned and how I always thought is why I carried the concept with me into programming. State machines were central in implementing VHDL. Subsequently, my C programs kind of look like my VHDL did. One observation I've made--those with an engineering background often write code dominated by boolean logic and switch statements very obviously describing a state machine, and those who have an abundance of programming courses don't.

  41. mmm!!! pop machine!!! by WebCowboy · · Score: 1

    Such fond memories! The pop machine is the "Hello, world!" of Engineerland!

    Of couse, these days thanks to Microsoft, we have "popmachine.NET". What once was implemented with a smattering of TTL logic must now posess a Pentium chip, megabytes of RAM and embedded Windows with the .NET framework. At least now there's a book out there that will inform today's enlightened pop machine programmers how to use "state charts" to develop efficient C# code for such a beast.

  42. Statecharts, UI, tools by Michael+Schuerig · · Score: 1

    A book about using statecharts for UI design and implementation

    Ian Horrocks
    Constructing the User Interface with Statecharts
    Addison-Wesley 1999

    Robert Martin's state map compiler for/in C(++) and Java
    http://www.objectmentor.com/resources/downlo ads/in dex

    Charles Rapp's state machine compiler
    http://smc.sourceforge.net/

    Michael

  43. What Statecharts Are by Aron+S-T · · Score: 3, Insightful

    I wrote about this in an internal reply but apparently people didn't seeit and are continuing to make some very ignorant statements about Statecharts.

    Statecharts are not a fancy way to do state machines. They are an extremely sophisticated graphics based notation with a formal mathematical semantics for modelling reactive systems. The ideas behind statecharts were developed by David Harel and Amir Pnueli (a winner of the prestigious Touring award and a world expert in Temporal Logic which heavily influenced the semantics of Statecharts).

    I was one of the early programmers (later manager) in the company that Harel and Pnueli founded in the early 80s. Because of its mathematical basis, we were able to build a tool that "executed" the statechart designs - not a probabilistic execution, but more akin to a mathematical proof done via a computer program.

    This isn't just a nice toy. It was used by companies like Alsthom-Alcatel to build the high-speed TGF train. The reactive model of the train was designed in Statecharts and the model executed. In this way they were able to discover serious flaws in the design (e.g. situations where the doors would open while travelling at high speeds). The only alternative to doing this is to build prototypes and do real world testing. By finding flaws in the very earliest design stage, the company was able to save millions of dollars and perhaps some lives.

    For more online information see:

    http://ilogix.com/quick_links/white_papers/index .c fm

    There is also a paper about Statechart semantics which I am listed as an author out there, but I have only found citations online. UML adopted Harel's Statecharts with some minor modifications, as part of the standard. They never claimed to invent it.

    Disclaimer: I still have some stock options in i-Logix which was founded in 1984 but never did go public.

  44. oh really? by BurKaZoiD · · Score: 1

    those with an engineering background often write code dominated by boolean logic and switch statements very obviously describing a state machine, and those who have an abundance of programming courses don't.

    I take offense to your to your boolean statement of programmers being one or the other. You may have to revise your logic to include an indeterminate state: those of us who have the same background as you and traditionally prefer to code the way you describe for the most part, but have to dumb our programs down so those business programmers (or power users, as I like to call them when I'm in a good mood; or fucktards when I'm feeling particulary nasty) who took an abundance of programming courses can understand them. Proof that the universe cannot be described strictly in states of true or false!

  45. Re:C and C++ by be-fan · · Score: 2, Insightful

    That's funny. On my machine, Intel C++ 7.x compiles a simple std::string/std::vector test into code that executes slight faster than the equivilent const char */const char ** test. Unless you have the time to hand optimize every little data structure, the STL will be faster in the long run. I always find it silly when I read C books, and see something like "a linked list isn't the most efficient data structure for this, but this operation isn't *that* critical, and using a list saves implementation complexity." If we were using the STL, you could just use whatever data structure was best suited to the task at hand, without worrying about implementation complexity!

    --
    A deep unwavering belief is a sure sign you're missing something...
  46. Just another hammer by Anonymous Coward · · Score: 0

    And for some people everything will look like a nail. We evaluated this book/methodology recently for a project that I work on, and found it to be overkill for what we wanted. Statecharts/FSMs are great for the niches that suit them (stateful protocols, parsers, critical systems) but for our needs, it was too much. If your project works within strict design parameters, and you can take the time to design the UML/statecharts/FSM then this will be a good tool. If (like us) the requirements and design are more fluid, then you will likely find yourself hampered by this, as the design cannot be known until you've coded a little.
    Also, Quantum comes from the fact he has a PhD in nuclear physics (and likes to tell you about it!), so he understands the analogy. Basically if you've coded a statemachine before, there won't be too much new in here.

    Cheers

    1. Re:Just another hammer by JonKaye · · Score: 1
      If (like us) the requirements and design are more fluid, then you will likely find yourself hampered by this, as the design cannot be known until you've coded a little.

      Boy, I had to jump in on this one.

      True, not all projects benefit from statecharts. If you have something simple to do, you do it simply. However, the poster's comment about fluid designs actually makes a strong case for using a rigorous design methodology. There's nothing wrong with coding a little bit and then revising designs, but in a rapidly-changing environment, you need to use a solid methodology so you don't end up with spaghetti design and code.

      Ian Horrocks, in his book Constructing the User Interface with Statecharts, contrasts the traditional "bottom-up" design/programming approach with the "top-down". The bottom-up is kind of code as you go, and quickly becomes a real mess (and much more prone to bugs). The top-down approach is about thinking at the high-levels of behaviors for the system, and progressively working down the branches. Statecharts (and even linear FSM's, as appropriate), are an excellent way to organize thoughts, designs, and then eventually the programming.

      Sorry to go off on a project that you say statecharts are overkill for, but even based on your short description, it sounds like you may need them more than you realize.

      -jonathan

      --
      Jonathan Kaye, PhD
      http://www.amethyst-research.com
      http://www.FlashSim.com
  47. The original statechart sources by marhar · · Score: 1
    Statecharts were originally developed by David Harel. His original paper is here: Statecharts.pdf


    He is an ACM Fellow, whose citation reads


    For his fundamental work in various areas of theoretical science, his invention of the visual language of statecharts for specifying reactive systems, and his expository contributions, especially via the widely acclaimed 1987 book "Algorithmics, the Spirit of Computing".

    If you are interested at all in theoretical computer science, you should read his book, which is coming out in a 3rd edition this year.
    1. Re:The original statechart sources by LCamel · · Score: 1

      Marhar's post should be moded as informative 5. As it stated in the abstract, statecharts extend
      conventional state machines and state diagrams. They are different.

  48. AI Interface Standards: Report of the GDC 2003 by Anonymous Coward · · Score: 1

    Subject: AI Interface Standards: Report of the GDC 2003 Roundtable

    The roundtable discussion from the Game Developers Conference was recently
    posted. One area that may be of interest is Session 6.

    Session 6:

    * Finite State Machines
    Objectives
    Identify how FSMs are commonly embedded in games
    Define a common language to describe finite state machines
    Define an XML description of FSMs for interoperability between tools
    Define an API whereby FSMs can be efficiently and easily interfaced with
    other systems

    Definitions
    Overview like UML statecharts, with some simplifications FuSM, HSM
    XML Description

    See the link: http://www.ai-center.com/events/gdc-2003-roundtabl e/

  49. its not Java... drive on by Anonymous Coward · · Score: 0

    at least that is what many decision makers would say. I never understood why there is such a large pool of ready fools out there whom will dictate specific implementations for no better reason than that it sounds cool. Sure, saying something like "Yes, but we want something extensible and modular since we will be adding to its feature set in the future often" is great. Saying, "We want Java because it is so good at networking, blah blah blah" Well if you are aware of that when why did you not simply get some programmers and instead gathered up architects, engineers and various analysts? Save money and develop it yourself. Granted there is nothing really "wrong" with this approach but they should not be too surprised if problems arise soon after development due to a lack of open minded planning.

  50. Tools galore ... by Anonymous Coward · · Score: 0

    There are many many tools, some of them are VERY interesting - Uppaal and XJTek are from Europe and have very nice user interfaces ... (some result from google and other)

    DiaGen [http://www2.informatik.uni-erlangen.de/DiaGen/ind ex.html]

    DOME [http://www.htc.honeywell.com/dome/]

    STATEMATE [http://www.ilogix.com/products/magnum/index.cfm]
    Rhapsody [http://www.ilogix.com/products/rhapsody/rhap_inc. cfm]

    Rational Rose [http://www.rational.com]

    tateflow [http://www.mathworks.com/products/stateflow/]

    XJTek [http://www.xjtek.com/products/xjcharts/]

    Poseidon for UML [http://www.GentleWare.com]

    ArgoUML [http://argouml.tigris.org/]

    BetterState Lite [http://www.windriver.com/products/html/betterstat e.html]

    visualSTATE [http://www.iar.com/Products/VS/]

    Uppaal [http://www.uppaal.com]

  51. Why, You're RIGHT! by Anonymous Coward · · Score: 0
    "All statecharts are is a better notation for documenting an FSM than a traditional state diagram."

    Let's deconstruct that statement:

    start state:

    • traditional state diagram represents as a circle with a "greater than sign" (e.g., >O)
    • UML represents as a filled-in circle
    intermediate states:
    • traditional state diagram represents as a circle
    • UML represents as a rectangle with rounded edges
    terminal state(s):
    • traditional state diagram represents as a circle within a circle
    • UML represents as a filled-in circle within a circle
    Yep, that's definitely "better"...
    1. Re:Why, You're RIGHT! by DogIsMyCoprocessor · · Score: 1

      Ummm ... guess you don't know what a statechart is, do you, Ms. AC?

      --

      "And this is my boy, Sherman. Speak, Sherman." "Hello." "Good boy."

    2. Re:Why, You're RIGHT! by Anonymous Coward · · Score: 0

      D00D, face it, you've been 0WN3D!

  52. This is a great book by iGN97 · · Score: 1

    This is a great book which concisely explains state charts, their application and the numerous ways to implement them.

    The illustrated examples of how hierarchical state machines really work are great for anyone looking to really utilize the concepts embraced by among others the UML to their full potential.

    That said, the approach used by the supplied framework is not without flaws (exception safety versus Run-To-Completion discrete steps, etc), as pointed out in discussions on USENET. Whether it fits your need will ultimately be a decision you have to make for yourself, no framework will fit every occasion. The main strength of the book, IMHO, lies in the clear explanations of concepts and implementation, not only in the supplied framework.

    As a sidenote: I misplaced the CD that comes with the book and emailed the author. He replied within the hour, and he had put the full CD zipped on an FTP-site and provided me with a login/password. You've gotta love that kind of response.

    All in all, I pretty much agree with the review and think the book deserves a strong 9/10. I recommend it to anyone who wants to rethink the way they currently write applications.

  53. "submachines"? by Anonymous Coward · · Score: 0

    I think the UML mechanism to express a hierarchy of states is called "submachines". It's hailed as the Next Coming, but it's similar to the decomposition of "processes" into subprocesses in the now out-of-favor Structured Analysis.

  54. Hierarchical State Machines by obobo · · Score: 1
    Yes, the book is mainly about implementing HSMs. One of his classes is called "QHsm", for example. The distinction is that a Statechart is the drawing of the HSM (Samek just uses Visio for that).


    I'm a little surprised that the poster didn't use the term, it's not like Samek doesn't use it everywhere in his book.


    The first half of the book is just exploring different ways of implementing FSMs/HSMs in C and C++. It doesn't seem like a hard thing to do, but a simplistic version with nested switch/case statements is really a recipe for hard to maintain code.


    The sencond half of the book though, explains Samek's "Quantum Framework", of interacting HSMs. I don't think that this is earth-shattering, but it's not the way most people are taught to code in C/C++, and I think it is a neat framework to use, especially in embedded/safety-critical systems.

  55. Don't discount UML...yet by grimsweep · · Score: 1
    UML is a worthy idea, and it can be saved. But people will have to realize "there is no silver bullet for software development". It won't make the problems go away, but hey, at least it's a starting point for software development more than two people can agree on.

    Plus, it's rooted in object-oriented design. That, at the very least, is a step in the right direction (i.e. away from the long-term logistics nightmare of functional decomposition) . Keep in mind, however, it's not a method. What you do with it determines it's effectiveness.

  56. how does it relate to "Executable UML"? by roundand · · Score: 1

    I've just finished reading Executable UML: A Foundation for Model Driven Architecture which basically implements the Schlaer Mellor methodology in a subset of UML, as part of a project to create the compilable and and executable UML of the title.

    I have a lot of time for Schlaer Mellor. As a methodology coming from the real-time world, it takes my softer async requirements (eg client-and-server or browser-and-application) well in its stride.

    It's also very much based on UML statecharts, and if anyone has read both I'd like to know how these two books compare.

  57. Looks a lot like... by infernalC · · Score: 1

    The description of a statechart is remarkably similar to my understanding of Markov chains. Markov chains are representations of finite state systems used by mathematicians. There are several instances of folks attributing the 'invention' of statecharts to particular computer scientists in the discussions below. I think it would be more accurate to say that a cs person pioneered the implementation of [degenerate] Markov chains as a cs application.

    Explanation of [degenerate]:
    Markov chains can be represented by both matricies and graphs. The primary difference I see between a graphed Markov chain and a statechart is that the Markov transitions are typically weighted. Knowing the event probabilities allows you to do some rather interesting stuff, like make predictions as to the number of trasitions before entering a terminal state, etc.

    1. Re:Looks a lot like... by H*(BZ_2)-Module · · Score: 1

      A Markov chain can be defined as a finite state machine with a probability assigned to each transition. The history of if the theory is firmly rooted in probability theory. Key figures include Markov, Wiener, and Kolmogorov, all of whom were definitely mathematicians.