iluwatar / iluwatar/java-design-patterns
Finite State Machine pattern
Nobody has claimed this yet.
- 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:
- States: Define the possible states the system can be in.
- Transitions: Define the rules or conditions that trigger a change from one state to another.
- Events: Actions or occurrences that cause state transitions.
- Context: Maintains the current state of the system and facilitates state transitions.
- State Interface: Defines the behavior associated with each state. Each state implements this interface to define its specific behavior.
References:
- State Design Pattern - Refactoring Guru
- State Machines - Martin Fowler
- GitHub Contribution Guidelines
Acceptance Criteria:
- Implement the FSM pattern with at least three distinct states and the transitions between them.
- Create a context class that maintains the current state and handles state transitions based on events.
- Provide example scenarios demonstrating the FSM pattern, including state definitions, transitions, and event handling.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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