InstituteforDiseaseModeling / covasim

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

Using Aggregation in population.py #341

Closed B-9991 closed 3 years ago

B-9991 commented 3 years ago

### The Problem: I noticed that the population.py file serves 2 main functionalities, one that has to do with making Population and another that takes care of creating Contacts. However, the population.py file didn't have any design pattern that would maintain a connection between classes or entities nor achieve an association.

### The Solution: My solution was to create 2 classes in an Aggregate Pattern such that it bounds functions based on what they serve. This design would help build a unidirectional relationship between Populations (Root class) and Contacts Class (aggregate class inside the bound). This helps navigate the function calls of external and internal files only through the root class, which helps in simplifying the relationship between entities as well as knowing that other parts of the system are not fetching its children, modifying them, and saving them without its knowledge

### The Goal: Population.py file establishes a Class Population contains Class Contacts type of a relationship.