Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard pattern for implementing state machines using java?

Tags:

java

One way i could think about is having a class which listens to events and has the different states stored in variables.

Is there a standard pattern for implementing state machines using java?

like image 760
Siva Avatar asked Aug 10 '11 06:08

Siva


3 Answers

The article I read before seems to be down right now, but if you Google enough you should be able to find other sources on how to implement finite state machines using Java enums.

Found it: http://www.javacodegeeks.com/2011/07/java-secret-using-enum-to-build-state.html

like image 132
Alistair A. Israel Avatar answered Sep 28 '22 07:09

Alistair A. Israel


state pattern can be used. See an example implementation in C++ here.

like image 22
Aravind Yarram Avatar answered Sep 28 '22 08:09

Aravind Yarram


I found this article very useful when I had to implement the state pattern: State Design Pattern using java .. A different approach!

like image 31
user802421 Avatar answered Sep 28 '22 09:09

user802421