-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
The codebase contains extensive SELECT TYPE dispatch logic scattered throughout business logic in fortplot_figure_core.f90, violating the SOLID principles, specifically:
- Open/Closed Principle: Business logic must be modified to add new backends
- Dependency Inversion: High-level modules directly depend on concrete backend types
- Single Responsibility: Figure module handles both orchestration and backend-specific rendering
Evidence
Found 14 instances of backend-specific type checks across 3 modules:
- fortplot_figure_core.f90: 8 instances
- fortplot_legend.f90: 4 instances
- fortplot_animation.f90: 2 instances
Examples include:
- Direct type checking for png_context, pdf_context, ascii_context
- Backend-specific rendering logic mixed with business logic
- Conditional execution based on backend type
Impact
- Adding new backends requires modifying core business logic
- Tight coupling between high-level and low-level modules
- Difficult to test business logic in isolation
- Violates architecture principle: 'NO SELECT TYPE IN BUSINESS LOGIC'
Required Fix
- Move all backend-specific logic to backend implementations
- Use polymorphic interfaces to hide backend differences
- Configure backend behavior at initialization time
- Remove all SELECT TYPE from business logic modules
Affected Files
- src/fortplot_figure_core.f90
- src/fortplot_legend.f90
- src/fortplot_animation.f90
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working