Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartPlotter simplification by delegating each plot type to a separate function file #582

Conversation

guillaume-vignal
Copy link
Collaborator

@guillaume-vignal guillaume-vignal commented Oct 3, 2024

Fixes: #581

Description

In this PR, we have initiated the refactoring of the SmartPlotter class by extracting the plotting logic into separate functions, each housed in its own Python file. The goal of this first phase is to keep the core data processing and display strategy logic intact while decoupling the plotting responsibility. This helps in simplifying the class and making the code more modular, maintainable, and testable.

Key Changes:

  • Decoupled Plotting Functions: Each type of plot previously managed by SmartPlotter has been moved to its own Python file as a standalone function. These functions are now responsible for rendering the respective plots.

  • Updated SmartPlotter: The SmartPlotter class remains in charge of preparing the data and determining which plot to display based on the use case. The class now delegates the actual rendering of the plot to the newly created plotting functions.

Benefits:

  • Improved Code Modularity: Each plot type has been isolated in its own file, following the single responsibility principle. This simplifies the structure of the code and makes individual components easier to understand and maintain.
  • Simplified SmartPlotter: By moving the plotting logic out, SmartPlotter is now focused on handling data and managing display strategies, rather than also managing the intricacies of every plot.
  • Easier Testing and Debugging: With plot types separated, it is now easier to write unit tests for each individual plot, ensuring that the visualization logic works as intended without needing to test the entire class at once.
  • Future Extensibility: New plot types can be added in the future by simply creating new functions and connecting them to SmartPlotter, without needing to modify the core class itself.

Next Steps:

This is just the first step in simplifying the SmartPlotter class. Future refactoring efforts could focus on further simplifying the data processing and display strategies, or on improving the interface for selecting and configuring plots.

@guillaume-vignal guillaume-vignal self-assigned this Oct 3, 2024
@guillaume-vignal guillaume-vignal added the enhancement New feature or request label Oct 3, 2024
@guillaume-vignal guillaume-vignal merged commit 8a50775 into MAIF:master Oct 4, 2024
@guillaume-vignal guillaume-vignal deleted the feature/smartplotter_simplification branch October 4, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplification of SmartPlotter Class
2 participants