|1.0||Background on UML, Eclipse UML, and State Diagrams|
|2.0||Creating a State Diagram|
|3.0||Creating Objects in a State Diagram|
|4.0||Tips and Tricks|
UML (Unified Modeling Language) was developed by Grady Booch, James Rumbaugh, and Ivar Jacobson, at Rational Software Corporation in 1997, for a standard way to model the structure of large applications. The UML is a standard maintained by the Object Management Group (OMG). The current version of UML is 2.0. UML provides a standardized way of modeling software, so the everyone can understand a given model. UML has several different modeling types: class diagram, sequence diagrams, state charts, and Use Cases to name a few. This tutorial will introduce programmers to creating state diagrams in Eclipse UML.
Eclipse UML is an Eclipse plug-in developed my Omondo. There is a free edition and a studio edition of Eclipse UML. The free edition will cover the modeling needs for CSC 326. You can download Eclipse UML here. After you have downloaded Eclipse UML, double click the jar file, which will then run an installer program. This will install Eclipse UML as a plug-in. We are using Eclipse UML release 220.127.116.1150718. You need to have the Eclipse Modeling Framework (EMF), Graphical Editor Framework (GEF) and UML2 Eclipse plug-ins installed. These are all Eclipse projects, and you can install them by connecting to the Eclipse update site inside of Eclipse (see Installing Plugins in Eclipse tutorial)
State Diagrams are used to describe the different states and state transitions of an object in the system. State Diagrams are not able to directly translate to code, so we cannot use them in Rational XDE to generate code based on the diagram, however, State Diagrams can be useful on their own to help model the behavior of a program in order for a programmer to better understand the intricacies of the code they are writing.
The key elements of a State Diagram are, of course, the states. There are three kinds of states: initial (or start), final, and regular states where things can happen. Inside of a state there can be entry and exit conditions as well as things that are done when the object is inside the state.
To move from state to state we have transitions. Transitions can be unconditional which means that when the activities of a state are complete a transition is automatically moved to another state. There can also be events that trigger a transition. In the CoffeeMaker example, the coffee maker waits until the user inputs a command. This command would trigger a transition to a particular state.
States can also contain an internal state diagram. It can be a parallel diagram in which there are multiple states executing at once, or the diagram can just contain a single string of events with its own start and finish states. When the final state is reached the parent state is exited.
For more detailed information about State Diagrams, check out Chapter 10 in Martin Fowler's UML Distilled.
Since state diagrams model the paths through a system, state diagrams are not tied to the code in a project.
The state diagram file is stored in the source directory or package of the associated source code. You can also create state diagrams in another folder of the project.
2.1 There are three ways to create a state diagram:
2.2 Press Next. Give the state diagram a file name. All state diagrams end in a .utd extension.
Below are the icons on the state diagram tool bar. These are displayed at the top of the State Diagram editor window. A discussion of each of the tools is also below.
To add one of these components to a diagram, select the component and drag the curser from a starting point to an ending point in the editor. When you are creating an state, you will need to drag a rectangle of the size you want the state to be in the diagram. The connector icons will need to be dragged from a source object to a destination object.
Creating a State
States are allowed to have internal state information and transitions. You can create these internal transitions when you create a state in the State Diagram editor. Press the add button, and specify the event name, arguments, condition guard, and action of the transition.
4.1 If you wish to see more of your state diagram you can zoom out using the zoom feature located in the toolbar.
Show your state diagram to your TA for credit.
Back to Software Engineering Tutorials