How mikeynap/hodoku works
Project Type and Purpose
• Hodoku is a standalone Java/Swing desktop application for generating, solving, training on, and analyzing standard Sudoku puzzles.
• It is packaged as a single JAR that runs on any Java 1.8+ runtime and supports two languages (English/German).
File‐Structure Analysis
• src/sudoku – all GUI classes (dialogs, panels, main window, event handlers)
• src/solver – solver engine interfaces and a suite of concrete solving strategies (Strategy Pattern + Factory)
• src/generator – puzzle‐generator classes, including factories and background threads for asynchronous generation
• src/intl – ResourceBundle properties for I18N (English/German)
• src/help – HTML user manual pages
• tests – a minimal smoke‐test entry point
• Other artifacts: templates.dat, showcase assets, build configs
README Insights
• Main purpose: Sudoku solver/generator/trainer/analyzer
• Highlights multi‐threaded background puzzle generation, a flexible “find all steps” feature, plugin‐like solver strategies, and extensive user preferences
Main Components
a. User Interface Layer (Blue)
• MainFrame / Main (entry point)
• Various Dialogs/Panels (e.g., AllStepsPanel, CellZoomPanel, ConfigDialog)
• Help Viewer
b. Controller/Coordinator (Light Blue)
• GuiState / Options classes
• Event dispatch/Action listeners in GUI components
• FileDrop, ListDragAndDrop helpers
c. Model Layer (Green)
• Sudoku, SudokuCell, Candidate, SudokuSet classes
• Entities representing the puzzle state and user annotations
d. Solver Engine (Orange)
• SudokuSolverFactory builds a SudokuSolver composed of multiple AbstractSolver implementations
• Individual Solvers (e.g., BruteForceSolver, FishSolver, WingSolver) following a Strategy Pattern
• SudokuStepFinder produces step-by-step explanation objects
e. Generator Engine (Orange)
• SudokuGeneratorFactory with GeneratorPattern implementations
• BackgroundGeneratorThread for asynchronous puzzle creation
f. Resource Manager / External Resources (Gray)
• I18N bundles in src/intl
• Help HTML pages
Component Interactions and Data Flows
• The UI layer raises user events → Controller passes requests to Model / Engines
• Generators and Solvers run (possibly in background threads) → update Model with new puzzle state or solution steps
• Controller/UI bind to Model changes → re-render panels/dialogs
• Resource Manager feeds localized strings and help pages into UI components
• ConfigDialog writes user preferences to disk; Options reads them on startup
Architectural Patterns & Principles
• MVC: UI components (View) separated from Model (Puzzle state) and Controllers
• Strategy Pattern: each solving technique implements a common interface; new strategies can be plugged in
• Factory Pattern: SolverFactory and GeneratorFactory hide concrete implementation choices
• Observer / Listener: UI updates in response to model or background‐thread events