Problem
The codebase currently uses an inconsistent hybrid approach with both mixins and services, creating architectural complexity and maintenance burden.
Issues with Current Architecture
-
Fragile Mixin Dependencies: Mixins like StationarityMixin blindly assume host classes have certain attributes (self.residuals) without explicit contracts
-
Multiple Inheritance Complexity: Diamond inheritance patterns create MRO issues and unpredictable behavior
-
Single Responsibility Violations: Classes like BaseTimeSeriesBootstrap (737 lines) and TimeSeriesModel (770 lines) violate SRP by handling validation, serialization, sklearn compatibility, bootstrap logic, and state management
-
Inconsistent Pattern Usage: Some functionality uses services, others use mixins, creating confusion about architectural direction
Concrete Examples
Hidden Dependencies in Mixins - StationarityMixin assumes self.residuals exists
Complex Multiple Inheritance - WholeResidualBootstrap inherits from ModelBasedBootstrap AND WholeDataBootstrap
God Object Pattern - TimeSeriesModel has 770 lines doing everything
Solution: Pure Service Architecture
Move to a 100% service-based architecture with explicit dependencies and single inheritance only.
Benefits
- Explicit Dependencies: Services declare exactly what they need
- Easy Testing: Each service can be tested in isolation
- Clear Contracts: No hidden assumptions about host class structure
- Single Inheritance: Eliminates MRO complexity
- Modular Composition: Features composed through service injection
Migration Plan
Phase 1: Extract Mixin Functionality to Services
Phase 2: Eliminate Multiple Inheritance
Phase 3: Decompose Monoliths
Phase 4: Update Tests and Documentation
Success Criteria
This refactoring will result in a much more maintainable, testable, and understandable codebase that follows clear architectural principles.
Problem
The codebase currently uses an inconsistent hybrid approach with both mixins and services, creating architectural complexity and maintenance burden.
Issues with Current Architecture
Fragile Mixin Dependencies: Mixins like StationarityMixin blindly assume host classes have certain attributes (self.residuals) without explicit contracts
Multiple Inheritance Complexity: Diamond inheritance patterns create MRO issues and unpredictable behavior
Single Responsibility Violations: Classes like BaseTimeSeriesBootstrap (737 lines) and TimeSeriesModel (770 lines) violate SRP by handling validation, serialization, sklearn compatibility, bootstrap logic, and state management
Inconsistent Pattern Usage: Some functionality uses services, others use mixins, creating confusion about architectural direction
Concrete Examples
Hidden Dependencies in Mixins - StationarityMixin assumes self.residuals exists
Complex Multiple Inheritance - WholeResidualBootstrap inherits from ModelBasedBootstrap AND WholeDataBootstrap
God Object Pattern - TimeSeriesModel has 770 lines doing everything
Solution: Pure Service Architecture
Move to a 100% service-based architecture with explicit dependencies and single inheritance only.
Benefits
Migration Plan
Phase 1: Extract Mixin Functionality to Services
Phase 2: Eliminate Multiple Inheritance
Phase 3: Decompose Monoliths
Phase 4: Update Tests and Documentation
Success Criteria
This refactoring will result in a much more maintainable, testable, and understandable codebase that follows clear architectural principles.