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>
20 lines
598 B
C#
20 lines
598 B
C#
namespace SawCut.Nesting
|
|
{
|
|
/// <summary>
|
|
/// Default implementation of IEngineFactory that creates AdvancedFitEngine instances.
|
|
/// Can be extended to support different engine types based on configuration.
|
|
/// </summary>
|
|
public class EngineFactory : IEngineFactory
|
|
{
|
|
public IEngine CreateEngine(double stockLength, double spacing, int maxBinCount)
|
|
{
|
|
return new AdvancedFitEngine
|
|
{
|
|
StockLength = stockLength,
|
|
Spacing = spacing,
|
|
MaxBinCount = maxBinCount
|
|
};
|
|
}
|
|
}
|
|
}
|