Visualize Business Rules with Statecharts

Because statechart diagrams are visually intuitive, they’re great for capturing business rules in a way that your stakeholders can understand. Statechart diagrams show the valid states that a business entity can take, and the events that make the entity change state.

Suppose you are defining requirements for the order management system of a business that sells customized products. Consider the business rules and workflow for a custom order. The order has to be tracked through the process of taking, planning, fulfilling and delivering it.

To create a statechart diagram (also known as a state diagram or state-transition diagram), think about the different states that an order can take. Each state is a distinct status and is drawn as a rectangle with rounded corners.

 statechart1

Show the valid ways the order can move from one state to another by connecting the states with transitions. The diagram begins with a start state (a filled small circle) and ends with a stop state (a small filled circle within a larger concentric ring). Transitions between states are triggered by events. You can label each transition with the event that caused it to happen. For example, when an order is placed, the order enters the New state (until something else happens).

 statechart2

The statechart diagram will help ensure you and your stakeholders have the same understanding of the business rules. You’ll also discover new business rules by walking through the diagram. For example, can an order be canceled once it is in progress? There’s probably a business rule that determines if and when that can happen.

Consider a business rule that states an in progress order can only be cancelled with a manager’s approval. We can add that to our statechart diagram using a guard condition. Guard conditions are like gates that only open under certain conditions. Use a bit of text to state the condition that has to be true in order to follow a transition (e.g. “Manager Approval”).

statechart3

As you are developing requirements, you’ll likely discover new states, or realize that other states aren’t valid. Keep your states at a level that is of interest to your business stakeholders. It’s not necessary to capture every possible state – just the ones that are meaningful in the scope of your requirements.

Getting stakeholders to actually read requirements is always a challenge. Put six important paragraphs of requirements next to a diagram and guess what your readers will study. The diagram, of course – everybody likes pictures. Without any training, a business stakeholder can look at a statechart diagram, understand it, and point out where it falls short. This makes the statechart diagram a valuable tool for getting you and your readers on the same page with regard to business rules.



Comments (5)

9/21/2009 3:51:22 PM #

csmith

Great Idea.. However I do not see the support for such diagraming in the products diagram creation section. How would you suggest we use this info with your product? Example the Start and Stop Graphics you suggest in your article do not seem to be available shapes within the diagraming tools.

csmith United States


9/22/2009 9:12:28 AM #

Doug

Hi, I think I can answer that one.  There is no direct support for statechart shapes, so you will have to use shapes from the basic shapes library.  For example, for the stop graphic, create two circles, one slightly larger than the other.  Then change the fill to black on the smaller one and white on the other.  To get them aligned correctly, select them both and then right click and select align centers, then select align middles.  Finally group them.  The good news is that you will only have to do this once because you can create a new shape library for your own custom shapes (see the greenish toolbar above the shapes toolbox).  Once you have your own custom shapes library, drag your start shape from the diagram into the shape library.  You'll then be able to use it on any diagram.  Hope this helps. Feel free to contact support at serlio if you have any questions on this.

Doug United States


9/22/2009 3:09:11 PM #

Charu

Hi

On Smith's comment - when we, BAs try to represent something through diagrams to make it more visual to top level people who will not have time or patience to read details, it is more important to achieve that purpose than worry about what shapes are available with the diagrammatic tool that we use or the rules behind those tools. If the tool does not cooperate, we can express the above state chart even by using simple shapes on a word a document (if it comes to that!)!

Such diagrams are useful even for UI flow - to show a mock up of the screen in each of those boxes and show how the user moves through them. e.g. a box to represent the search dialogue screen, what happens if only 1 result is found, what happens if less than 20 results are found, what if more than 100 results are found, how the paging works, sorting works, etc - all can be easily shown with screen mock-ups within the boxes and people understand the flow very well.

Even for discussions of business models, simple circles are good enough ….as for top level people, more than the rules of the diagramming, the expression is more important!

Cheers
Charu

Charu New Zealand


9/23/2009 7:06:50 AM #

Matt Terski

Good point, Charu - I like to use statecharts to illustrate UI flow (maybe the topic of another article). Ryan over at 37signals recently wrote about his own notation for UI flow (37signals.com/.../1926-a-shorthand-for-designing-ui-flows), but I think the statechart is even simpler and easier to understand.

Matt Terski United States


9/28/2009 7:20:09 PM #

Mark Norton

The following is a brief extract from an article that presents a slightly different view of state change. If you think it interesting the article is at "http://tiny.cc/yLslV";


"Data and decisions both have important roles in this decision-centric approach – each showing a different and complementary view of the same system. Data models show the valid states of the system at rest; decision models describe the valid transitions between the states. However, it is the state transitions described by the decision models that generates value for any business, giving the decision model a primacy that is not shared by either data or process. In fact, we argue that it is the corporate strategy itself that defines when and how 'value creating' state changes occur, and that this is the ultimate foundation upon which decisioning approaches are built."

Mark Norton New Zealand


Pingbacks and trackbacks (2)

Comments are closed