Refactoring the HSSM class #630
Replies: 1 comment
-
@cpaniaguam few thoughts: Following the modularization approach, would we add the functions from separate modules as class-methods inside the hssm class (via a decorator e.g.)? I like the separation of concerns, but would need a quick example here to understand better how this would example play out. Also, it seems like the modularization refactor is something that can be done iteratively (module by module e.g.) over a span of time, without having an intermediate 'everything is broken until we have a new castle to inhabit' situation, which would be great true. Related, I would strongly advocate for working on the "model registration" functionality before this refactor (or during, if possible) and not make it contingent on that if not absolutely necessary. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The
HSSM
class is large and complex, making it difficult to maintain and extend. Before implementing the model registration abstraction it seems reasonable to refactor its functionality for readability and extensibility. I can think of two refactoring approaches: either modularization or composition with helper classes.Approach 1: Modularization
This approach involves breaking down the [HSSM] class into separate modules based on functionality. Each module will handle a specific responsibility, such as sampling, plotting, data handling, and model management.
Steps:
Create Separate Modules:
sampling.py
for sampling-related methodsplotting.py
for plotting-related methodsdata_handling.py
for data handling and preprocessing methodsmodel_management.py
for model saving and loading methodsMove Methods to Appropriate Modules:
HSSM
class and place them in the corresponding modulesHSSM
class and delegate tasks to the modulesPros:
Cons:
Approach 2: Composition with Helper Classes
This approach involves breaking down the HSSM class into smaller, more focused helper classes that handle specific responsibilities. These helper classes are then composed within the main
HSSM
class.Steps:
Create Helper Classes
SamplingHelper
PlottingHelper
DataHandlingHelper
ModelManagementHelper
Integrate Helper Classes:
HSSM
class.Pros:
Cons:
@digicosmos86 @AlexanderFengler Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions