You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to suggest the following refactor plan for PLEIADES as the current code architecture is a bit difficult to maintain and extend with new features:
High-Level Refactor Plan for PLEIADES Project
Importance Ranking
Task
Difficulty
Description
High
Introduce Classes for Modularization
Medium
Encapsulate key functionalities in classes such as PleiadesConfig (to handle configuration) and classes like SammyInputHandler, SammyOutputHandler, and SimDataProcessor to organize logic and responsibilities. This will simplify code reuse, testing, and maintenance.
High
Refactor Large Functions into Smaller Sub-Functions
Medium
Break down large functions into smaller, focused sub-functions that each perform a single task. This will improve code readability, testability, and reduce the risk of errors. Prioritize functions with deeply nested loops and conditionals.
High
Centralize Configuration Handling
Medium
Create a PleiadesConfig class that reads configurations from .ini files and makes them easily accessible. Ensure each module accesses configuration through this centralized point rather than reading the .ini files directly. This will eliminate redundant configuration access code and potential inconsistencies. See pydantics at the bottom for more info.
High
Enhance Error Handling
Medium-High
Implement consistent error handling across file I/O, parsing, and data processing using try-except blocks and informative logging. This will enhance robustness, making it easier to diagnose issues when they arise.
High
Expand Unit Test Coverage and Add Integration Tests
High
Improve the current test suite to include more comprehensive unit tests and integration tests that verify modules working together correctly. Emphasize testing of edge cases, exception handling, and configuration validation. This is essential to ensure code correctness as the refactoring proceeds.
Medium
Introduce Type Hinting for Functions
Low-Medium
Add type hints to functions to make it easier for developers to understand input and output types. This will also help with static analysis tools like mypy and improve the overall quality of the codebase.
Medium
Create Utility Modules for Common Operations
Medium
Create dedicated utility modules, such as file_utils.py for file handling, plot_utils.py for plotting, and data_utils.py for common data manipulations. This will reduce code redundancy and centralize key functionalities for easier updates.
Medium
Standardize Code Formatting and Naming Conventions
Low
We are already using pre-commit with ruff for code formatting, but the naming convention needs to be enforced for better readability.
Medium
Introduce Logging for Debugging
Medium
Replace print() statements with Python’s logging library for better control over the logging levels (INFO, DEBUG, WARNING). This will allow for better debugging and give users a better understanding of what is happening during runtime.
Low
Refactor Plotting Functions for Consistency
Low-Medium
If the code includes visualization, refactor all plotting functions to use a consistent style (e.g., colors, labels, and titles). Use helper functions in a utility module to avoid repeated code. This will improve consistency across the visual output.
Low
Adopt dataclasses for Simple Data Structures
Low-Medium
Replace simple data classes in sammyStructures.py or other files with Python’s dataclasses (if no validation required) or pydantic (validation needed). This will reduce boilerplate code and make data structures more readable and concise.
Low
Automate Configuration Validation Using Pydantic
Medium
Use a library like pydantic for validation of configuration parameters to make sure input configurations are validated before they are used. This is particularly helpful in catching incorrect or missing values early.
In addition to the code refactoring above, I would also like to suggest enable Github action for this repo (after unit tests are added and configured).
The text was updated successfully, but these errors were encountered:
I would like to suggest the following refactor plan for PLEIADES as the current code architecture is a bit difficult to maintain and extend with new features:
High-Level Refactor Plan for PLEIADES Project
PleiadesConfig
(to handle configuration) and classes likeSammyInputHandler
,SammyOutputHandler
, andSimDataProcessor
to organize logic and responsibilities. This will simplify code reuse, testing, and maintenance.PleiadesConfig
class that reads configurations from.ini
files and makes them easily accessible. Ensure each module accesses configuration through this centralized point rather than reading the.ini
files directly. This will eliminate redundant configuration access code and potential inconsistencies. Seepydantics
at the bottom for more info.try-except
blocks and informative logging. This will enhance robustness, making it easier to diagnose issues when they arise.mypy
and improve the overall quality of the codebase.file_utils.py
for file handling,plot_utils.py
for plotting, anddata_utils.py
for common data manipulations. This will reduce code redundancy and centralize key functionalities for easier updates.ruff
for code formatting, but the naming convention needs to be enforced for better readability.print()
statements with Python’slogging
library for better control over the logging levels (INFO
,DEBUG
,WARNING
). This will allow for better debugging and give users a better understanding of what is happening during runtime.dataclasses
for Simple Data StructuressammyStructures.py
or other files with Python’sdataclasses
(if no validation required) orpydantic
(validation needed). This will reduce boilerplate code and make data structures more readable and concise.pydantic
for validation of configuration parameters to make sure input configurations are validated before they are used. This is particularly helpful in catching incorrect or missing values early.In addition to the code refactoring above, I would also like to suggest enable Github action for this repo (after unit tests are added and configured).
The text was updated successfully, but these errors were encountered: