HOME JOURNALS CONTACT

Journal of Software Engineering

Year: 2010 | Volume: 4 | Issue: 3 | Page No.: 215-230
DOI: 10.3923/jse.2010.215.230
Using Java Enums to Implement Concurrent-Hierarchical State Machines
Jauhar Ali

Abstract: The aim of this study is to find an easy way for implementing concurrent-hierarchical state machines into efficient and encapsulated Java code. State Machine is one of the important diagrams in Unified Modeling Language (UML). In UML, State Machine is used to represent reactive behavior of a class of objects. Implementing a state machine has been difficult for programmers because the commonly used Object-Oriented Programming languages do not provide any explicit support. We present a new approach to implement state machines using Java Enums. In our approach, each state is represented as an enum-value. Hierarchical states and concurrent orthogonal regions within state machines are implemented by linking the related enum-values to each other. Our approach offers several benefits. First, using Java enums makes the resulting code compact, efficient and easy to understand. Second, the structure of the state machine is obvious in the implementation code. Third, the whole state machine's behavior is encapsulated within a single class (called StateMachine). The proposed code can serve as a Java implementation pattern for state machines.

Fulltext PDF Fulltext HTML

How to cite this article
Jauhar Ali , 2010. Using Java Enums to Implement Concurrent-Hierarchical State Machines. Journal of Software Engineering, 4: 215-230.

Related Articles:
© Science Alert. All Rights Reserved