refactor: Use interface abstraction for IModuleResultRepository enabled check#1733
Conversation
…ed check (#1526) Replace concrete type checks against NoOpModuleResultRepository with an IsEnabled property on IModuleResultRepository interface. This improves testability and follows the Dependency Inversion Principle. - Add IsEnabled property to IModuleResultRepository interface - Set IsEnabled => false in NoOpModuleResultRepository - Set IsEnabled => true in test implementations - Update ModuleExecutionPipeline to use _resultRepository.IsEnabled 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SummaryRefactors module result repository type checking from runtime type comparison to a polymorphic IsEnabled property. Critical IssuesNone found ✅ SuggestionsDocumentation Update Needed public class MyModuleRepository : IModuleResultRepository
{
public bool IsEnabled => true;
// ... rest of implementation
}This helps users understand that the interface now requires this property when implementing custom repositories. Verdict✅ APPROVE - No critical issues The refactoring improves the design by:
All test repositories correctly implement the new property. The only minor improvement would be updating the documentation example. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the module result repository pattern to use interface-based abstraction instead of concrete type checks, addressing issue #1526. The change improves testability and follows the Dependency Inversion Principle by removing direct dependencies on the NoOpModuleResultRepository concrete type.
Key changes:
- Added
IsEnabledproperty to theIModuleResultRepositoryinterface to indicate whether the repository performs actual storage operations - Replaced type checks (
GetType() == typeof(NoOpModuleResultRepository)) with property-based checks (IsEnabled) inModuleExecutionPipeline - Updated all implementations to provide appropriate
IsEnabledvalues
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/ModularPipelines/Engine/IModuleResultRepository.cs |
Added IsEnabled property with comprehensive XML documentation to the interface |
src/ModularPipelines/Engine/NoOpModuleResultRepository.cs |
Implemented IsEnabled => false for the no-op repository implementation |
src/ModularPipelines/Engine/ModuleExecutionPipeline.cs |
Replaced concrete type checks with IsEnabled property checks in two locations (historical result retrieval and result saving) |
test/ModularPipelines.UnitTests/ResultsRepositoryTests.cs |
Implemented IsEnabled => true in test repository mock |
test/ModularPipelines.UnitTests/ModuleHistoryTests.cs |
Implemented IsEnabled => true in both test repository mocks |
Review Summary: This is a clean, well-documented refactoring that successfully eliminates the code smell identified in issue #1526. The implementation is consistent across all affected files, maintains backward compatibility (adds a new property without breaking existing implementations), and follows SOLID principles. The XML documentation for the new property is clear and comprehensive. No issues found.
Summary
Fixes #1526
IsEnabledproperty toIModuleResultRepositoryinterface to indicate whether the repository is configured for actual storageIsEnabled => falseinNoOpModuleResultRepository(the default no-op implementation)IsEnabled => truein test implementationsModuleExecutionPipeline.csto use_resultRepository.IsEnabledinstead of concrete type checks againstNoOpModuleResultRepositoryThis change improves testability and follows the Dependency Inversion Principle by removing direct dependencies on concrete types.
Test plan
🤖 Generated with Claude Code