InstituteforDiseaseModeling / covasim

COVID-19 Agent-based Simulator (Covasim): a model for exploring coronavirus dynamics and interventions
https://covasim.org
MIT License
250 stars 223 forks source link

Aggregate pattern on parameters.py #324

Closed Daivakshi closed 2 years ago

Daivakshi commented 3 years ago

Introduction

This part of the code applies aggregate pattern on parameters.py by classifying immunity, prognoses, variants and vaccine parameters into different classes with parameters class as the root.

Changes

class parameters consists of functions make_pars and reset_layer_pars which initialises and creates the parameters and loads input data. This is the root class that does the major implementation. Rest of the functions in the method process and access the parameters, so these functions have been further classified into distinct parameters i.e. vaccine, immunity, etc.

class prognoses has all the functions responsible for accessing the parameter data on prognoses and functions for processing relative and absolute prognoses.

classes vaccinePars, variantPars and immunityPars contain functions for respective parameter types.

I have simply sorted the functions into classes that are in an aggregate relation to the parameters class which creates the parameter that are used in rest of the classes for processing information and data.

My Reasoning for Applying Aggregation

This helps simplify the code and classify the functions into clearly defined purposes. It makes the code easy to understand and gives a rough idea at a single glance. It tells the reader about the dependencies of classes like prognoses and vaccinePars on the parameter class. In addition, it also helps with the modification and refinement process of the code since it sorts the code on the basis of what it does, the refinement can be focused on the particular area that needs improvement.

cliffckerr commented 2 years ago

Thanks for the PR -- we're not considering major architectural changes currently, but we appreciate the contribution to open-source software!