state-machine

Python state-machine design

*爱你&永不变心* 提交于 2019-11-27 10:10:26
Related to this Stack Overflow question (C state-machine design) , could you Stack Overflow folks share your Python state-machine design techniques with me (and the community)? At the moment, I am going for an engine based on the following: class TrackInfoHandler(object): def __init__(self): self._state="begin" self._acc="" ## ================================== Event callbacks def startElement(self, name, attrs): self._dispatch(("startElement", name, attrs)) def characters(self, ch): self._acc+=ch def endElement(self, name): self._dispatch(("endElement", self._acc)) self._acc="" ## ===========

Design Pattern problem involving N states and transitions between them

偶尔善良 提交于 2019-11-27 09:37:53
问题 I have a problem at hand and I am not getting which design pattern to use. The problem goes as such: I have to build a system which has 'N' states and my system has to do a transition from any state to any other state depending on some conditions. Ex: On condition 1, movement from State 1 to 3 and on condition 2 from state 1 to 4. Even the transition from one state to other state can be done on 2 or more different conditions. For example, transition from State 1 to state 3 can be done when:

Workflow engine in Javascript [closed]

杀马特。学长 韩版系。学妹 提交于 2019-11-27 09:09:50
问题 Does anybody know a workflow engine (such as Spring WebFlow) for Javascript? We have a home-made framework that allows us to guide site navigation using JSON, but its quality is far from good. Edit based on given answers: the engine must run on the browser and reduce to minimum the number of requests to the server. 回答1: As suggested by katspaugh I'm posting the libraries I found as the answer. List of workflow libraries that I've found until now: XState - https://github.com/davidkpiano/xstate

uses for state machines [closed]

三世轮回 提交于 2019-11-27 04:02:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . In what areas of programming would I use state machines ? Why ? How could I implement one ? EDIT: please provide a practical example ,

implementing a state machine using the “yield” keyword

若如初见. 提交于 2019-11-27 03:50:52
Is it feasible to use the yield keyword to implement a simple state machine as shown here . To me it looks like the C# compiler has done the hard work for you as it internally implements a state machine to make the yield statement work. Can you piggy-back on top of the work the compiler is already doing and get it to implement most of the state machine for you? Has anyone done this, is it technically possible? It's feasible but it is a bad idea. Iterator blocks were created to help you write custom iterators for collections, not for solving the general-purpose problem of implementing state

get list of state_machine states

自作多情 提交于 2019-11-27 01:44:34
问题 We are using state_machine ( https://github.com/pluginaweek/state_machine ) in a project and would like to offer a form with a select that lets us choose a state. (this is for searching, not for setting). I can't seem to find a way to list out all the possible states? Surely there should be an automatic way of doing this, not having to hard-code a list of text somewhere. Thanks! 回答1: Something like: User.state_machine.states.map &:name 回答2: Just to add to this (because I'm constantly

Short example of regular expression converted to a state machine?

為{幸葍}努か 提交于 2019-11-27 01:11:49
In the Stack Overflow podcast #36 ( http://blog.stackoverflow.com/2009/01/podcast-36/ ), this opinion was expressed: Once you understand how easy it is to set up a state machine, you’ll never try to use a regular expression inappropriately ever again. I've done a bunch of searching. I've found some academic papers and other complicated examples, but I'd like to find a simple example that would help me understand this process. I use a lot of regular expressions, and I'd like to make sure I never use one "inappropriately" ever again. Sure, although you'll need more complicated examples to truly

How to Make a Basic Finite State Machine in Objective-C

一曲冷凌霜 提交于 2019-11-27 00:11:03
问题 I am attempting to build an FSM to control a timer in (iphone sdk) objective c. I felt it was a necessary step, because I was otherwise ending up with nasty spaghetti code containing pages of if-then statements. The complexity, non-readability, and difficulty of adding/changing features lead me to attempt a more formal solution like this. In the context of the application, the state of the timer determines some complex interactions with NSManagedObjects, Core Data, and so forth. I have left

C++ code for state machine

左心房为你撑大大i 提交于 2019-11-26 23:49:53
问题 This was an interview question to be coded in C++: Write code for a vending machine: Start with a simple one where it just vends one type of item. So two state variables: money and inventory, would do. My answer: I would use a state machine which has about 3-4 states. Use an enum variable to indicate the state and use a switch case statement, where each case has the operations to be done corresponding to each state and stay in a loop to move from one state to another. The next question: But

Use cases of the Workflow Engine

我们两清 提交于 2019-11-26 23:46:09
问题 I'd like to know about specific problems you - the SO reader - have solved using Workflow Engines and what libraries/frameworks you used if you didn't roll your own. I'd also like to know when a Workflow Engine wasn't the best choice and if/how you chose something simpler, like a TaskList/WorkList/Task-Management type application using state machines. Questions: What problems have you used workflow engines to solve? What libraries/frameworks did you use? When did a simpler State Machine/Task