Skip to content

Refactor StatsSelectView to Follow SOLID and DRY Principles #4

Description

@Zingzy

The current implementation of StatsSelectView contains complex, repetitive logic that violates SOLID (particularly Single Responsibility Principle) and DRY (Don't Repeat Yourself) principles. The view also lacks persistence across bot restarts. We need to refactor this component to improve maintainability, readability, and ensure view persistence.

Current Issues

  • Duplicate code across different chart generation sections
  • Oversized callback methods with multiple responsibilities
  • No mechanism for view persistence after bot restarts
  • Complex, nested conditional logic that's difficult to maintain
  • Mixed responsibilities (UI handling, data processing, chart generation)

Technical Details

  • Use the Strategy pattern for different chart types
  • Implement component persistence using Discord's custom IDs and a storage mechanism
  • Move chart configuration to a dedicated configuration class
  • Consider using dependency injection for better testability

Benefits

  • Cleaner, more maintainable code
  • Better separation of concerns
  • Easier to extend with new chart types
  • Views will persist across bot restarts
  • Improved testability
  • Reduced code duplication

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions