iluwatar / iluwatar/java-design-patterns

Finite State Machine pattern

Open
#203 34 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

epic: pattern info: help wanted type: feature
Dominant language
Java
Stars
94.7k
Forks
27.4k
Avg merge
3d 4h
Merged PRs (30d)
10

Description

Description:
The Finite State Machine (FSM) design pattern is a behavioral design pattern used to model the behavior of a system that can be in one of a finite number of states. The system transitions from one state to another in response to external events or internal actions. This pattern is useful in scenarios where an object’s behavior is dependent on its state, and the state can change in response to events.

Main elements of Finite State Machine pattern:

  1. States: Define the possible states the system can be in.
  2. Transitions: Define the rules or conditions that trigger a change from one state to another.
  3. Events: Actions or occurrences that cause state transitions.
  4. Context: Maintains the current state of the system and facilitates state transitions.
  5. State Interface: Defines the behavior associated with each state. Each state implements this interface to define its specific behavior.

References:

Acceptance Criteria:

  1. Implement the FSM pattern with at least three distinct states and the transitions between them.
  2. Create a context class that maintains the current state and handles state transitions based on events.
  3. Provide example scenarios demonstrating the FSM pattern, including state definitions, transitions, and event handling.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the FSM description and the linked State Design Pattern and State Machines references. Implement at least three states, their event-driven transitions, and a context class, then add example scenarios demonstrating the states, transitions, and event handling described in the acceptance criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.