State Design Query RRS feed

  • Question

  • Hi All,

             I am having a scenario, wherein, for the time being, I have 3 states viz. State1,State2 and State3 but under certain conditions it can be Stae12(combination of State1 and State2) or State13(combination of State1 and State3) or State23(combination of State2 and State3) and even State123(a combination of State1,State2 and State3). In future the states may increase and correspondingly the various combinations will also increase.If I go by if-else way, maintaining the code seems to be a nightmare.Also the actual State design pattern does not seem to exactly suit this scenario.Can anyone please suggest some suitable class design to design this scenario? Any sample code is highly appreciated.

    Thanks and Regards,


    Tuesday, December 17, 2013 1:33 AM

All replies

  • Have you looked windows workflow state machine?


    Sunday, February 16, 2014 9:52 PM
  • I think I got a hint.Will use Decorater and State Pattern together to construct the names of the states and have the same names in the DB State table as well.
    Tuesday, April 1, 2014 9:45 AM
  • hello there,

    the requirement is incorrect , yourself are in a confused . please understand the requirement thoroughly, then a class diagram.

    the combination state12 what is scenario it is being used here.Be very specific what is your requirement that you are looking for.

    Friday, April 11, 2014 5:00 AM