Jump to content
Sign in to follow this  
Jim C

Too many states?

Recommended Posts

Good morning,

 

I've been using your State Machine since you unleashed it on the world and have happily noticed a great improvement in my coding efficiency, as well as readability/maintainability/scalability. But, as I've been writing larger programs, I find myself with many, many states (including one for each paragraph in the test specification document).

 

Is there a problem (style or otherwise) with having many states, apart from the inconvenience of having to scroll down a long list? Is there anything you folks do to address this?

 

Thanks,

Jim

Share this post


Link to post
Share on other sites
Is there a problem (style or otherwise) with having many states, apart from the inconvenience of having to scroll down a long list? Is there anything you folks do to address this?

 

There isn't a real problem associated with having too many states. Right now, we don't have any tools to address having a lot of states, but we do find that there are a couple of tricks to making it easier to manage.

  • If you have a lot of states, you may want to look at your design and see if you really should be using multiple state machines.
  • Try to keep your states organized -- don't allow yourself to add states haphazardly to the case structure, make sure they are well grouped.
  • Some people at JKI have used alphabetic naming schemes to make it easier to sort their states, but we haven't really adopted that as a standard -- I'm just throwing this out there.

Share this post


Link to post
Share on other sites

I'll think about how I can redesign things in the next project! This one isn't unwieldy, it just takes a while to scroll between states. Perhaps I just need a scroll bar on the state selection list!

 

Thanks for answering.

Share this post


Link to post
Share on other sites
This one isn't unwieldy, it just takes a while to scroll between states. Perhaps I just need a scroll bar on the state selection list!

 

One other thing I've done recently in state machines with a lot of states is to avoid using the drop down for the state selection -- granted this only works in some situations... If you are working on a group of states that are related to each other you can use the 'next'/'previous' state arrow buttons rather than the state selection list. Its actually faster than trying to 'find' your current state and then find the nearby state that you want to navigate to. I find that occasionally this is helpful.

 

Good luck - I'm glad you've been able to use the JKI State Machine with success!

Share this post


Link to post
Share on other sites
One other thing I've done recently in state machines with a lot of states is to avoid using the drop down for the state selection -- granted this only works in some situations... If you are working on a group of states that are related to each other you can use the 'next'/'previous' state arrow buttons rather than the state selection list. Its actually faster than trying to 'find' your current state and then find the nearby state that you want to navigate to. I find that occasionally this is helpful.

 

Good luck - I'm glad you've been able to use the JKI State Machine with success!

Another tip is to hold the control key and spin the mouse wheel.

 

As far as success with the JKI State Machine, it's fast becoming the standard here. Three of us use it (although one guy has ruined it) and I'm teaching other developers to start using it. You guys are the best.

Share this post


Link to post
Share on other sites
  • Some people at JKI have used alphabetic naming schemes to make it easier to sort their states, but we haven't really adopted that as a standard -- I'm just throwing this out there.

I often use a delimted grouped string for stuff like this. Depending on your tastes, you can use a forward or reverse organizations. Say you had a group of states that turned a LED on, off, different colors, read it's state, etc:

 

LED.Set.Green

LED.Set.Red

LED.Set.Orange

LED.Set.Off

LED.Get.State

Share this post


Link to post
Share on other sites

Just in case anybody has the same problem I had and finds this post. There's a tool to solve this problem here.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.