State diagrams -Introduction

State diagrams will show the internal state of the system or part of the system. It may even just relate to a single object. The term state is worth exploring before we look at the specifics of a state diagram.

State is a computer science term which essentially means the current internal values of a running system. Instead of worrying about what we are storing we are interested in the actual values which will be stored at a given time. For most systems there will be a predictable path which data or objects will follow from instantiation to destructions. If you imagine a running system and then froze it in time. This would be considered a single state. If you pressed play and then paused it later then this would be a separate state.

So as a system runs it will change state. This is where state diagrams come in. We can use them to show how the system will move from one state to another and restrict any state changes which may be outside the requirements or maybe will break the requirements. Not every single state should be represented nor should every possible value be considered. There is a good reason for this.... It is that it is impossible! Computer systems are too complex to represent every possible state.

Coming back to state diagrams, we will want to create diagrams so they have some semantic meaning but also ensure that we do not get too bogged down in detail. The diagram below shows a possible state of a order placed for an on-line distributor.

The first state we will get to is “new order”. The big black dot represents the start of the state diagram. Based on the diagram this means that every order that arrives in the system must first enter the “new order” state which makes perfect sense.