Replace hard-coded engine instantiation with factory pattern
to enable dependency injection and improve testability.
Changes:
- IEngineFactory: Interface for creating engines
- EngineFactory: Default implementation using AdvancedFitEngine
- MultiBinEngine: Now accepts IEngineFactory via constructor
This eliminates the hard-coded dependency on AdvancedFitEngine
and allows for easy swapping of engine implementations through
configuration or dependency injection.
Benefits:
- Dependency inversion principle satisfied
- Engines can be mocked in tests
- Engine selection can be configured externally
- Single responsibility for engine creation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement Result<T> and Result classes to provide type-safe,
functional error handling throughout the application. This
eliminates the need for exceptions as control flow and provides
a consistent way to communicate success/failure.
Features:
- Result<T> for operations that return values
- Result for operations without return values
- Map() method for functional composition
- IsSuccess/IsFailure properties for easy checking
This pattern enables cleaner service contracts and eliminates
the need for out parameters and exception handling boilerplate.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Create CutListService and DocumentService to separate business
logic from UI concerns, following the service layer pattern.
Changes:
- CutListService: Handles bin packing algorithm orchestration
and data transformation from UI models to domain models
- DocumentService: Handles document persistence and validation
- Document: Removed Save/Load/Validate methods (now pure POCO)
- MainForm: Refactored to delegate to service classes instead
of containing business logic directly
Benefits:
- Improved separation of concerns
- Business logic can now be unit tested independently
- Removed MessageBox dependencies from business logic layer
- MainForm is now focused on UI concerns only
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace public mutable collection fields/properties with private
backing fields and expose them as IReadOnlyList. Add proper methods
for mutation (AddItem, AddItems, RemoveItem, SortItems).
Changes:
- Bin.Items: Now private with AddItem/AddItems/RemoveItem/SortItems
- Result.ItemsNotUsed: Now readonly with Add methods
- Result.Bins: Now readonly with Add methods
- Updated all engine classes to use new encapsulated APIs
This improves encapsulation and prevents external code from
bypassing business logic by directly manipulating collections.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove empty catch-and-rethrow blocks in Load() and Save() methods
that were catching exceptions only to rethrow them without adding
any value. This improves code clarity and exception propagation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove dangerous side effect where the Length property getter
was modifying the LengthInputValue field. Property getters should
be pure and not cause state mutations, as this violates the principle
of least surprise and can cause issues with data binding, serialization,
and debugging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>