Menu

Is there any possible way to create States Dynamically

Hemanth
2014-06-03
2014-06-24
  • Hemanth

    Hemanth - 2014-06-03

    We are Developing a Application Using SMC Everything is Fine Up to finally But i got New Requirement .The SMC has to Accepts Dynamic States From the User Input .
    Is there any possible way to Create states Dynamically in SMC if Yes can someone provide me links to tutorial

     
  • Charles Rapp

    Charles Rapp - 2014-06-04

    The short answer is: No. There is no way to dynamically create states in SMC. States are implemented as classes and transitions are class methods.

    This raises the questions:

    • Does it make sense to dynamically create states?
    • What does it mean to dynamically create states?
    • What is a state?

    Start with transitions. Transitions represent the events to which your object can respond. These events are defined up front. When you design an object, you decide which events that object needs to handle. There is a one-to-one mapping between events and transitions. A transition specifies how you respond to an event in a given state and the resulting state.

    So just as events/transitions are defined up front, so to are states. States are fixed entities because transitions are fixed. If you dynamically create a state, how will you get there? You will need to dynamically define transitions as well which take you to that new state. Since SMC translates transitions to methods, there really is no way to add a method to a class dynamically.

    But are dynamically created states the correct way to handle user input? Dynamic states would mean dynamic user input. Are you really saying that your FSM must handle absolutely any user input, event input that is entirely unknown when designing your application? My guess is that your software already places constraints on user input. Those constraints mean defined transitions. And defined transitions means defined states.

    If you provide me with a concise definition of the problem you are trying to solve, I will try to provide an SMC-based solution to that problem.

     
  • Hemanth

    Hemanth - 2014-06-24

    Thanks Charles Rapp. i will get back to u

     

Log in to post a comment.