Applying Aggregate Design Pattern to population.py Module
Introduction
I am a third-year computer science student. A part of the learning process for the Software Design course, we have to contribute to one of many given options of open source projects. For this particular project, we have to apply an aggregate design pattern to the chosen project publicly by making two pull requests.
Abstract
The code in population.py was unordered and unstructured, potentially losing unnecessary resources on reading and understanding the code. Mainly, some methods were given a class while others didn't have any. This is considered a bad practice in software design because it may lead to complexity, specifically low clarity on which parts of the code must be modified to make the improvement or future debugging. To solve this, I applied the aggregate design pattern by encapsulating the population class to emphasize the relation between the classes and methods such as:
Population – the root aggregate and contains all aggregated classes and methods
Population_setup – contains methods that help initialize the population parameters for the simulation
Population_trackers – contains methods to track population parameters (Already implemented)
Population_data – contains methods that save population and simulation data to disk
Why aggregation?
As mentioned before, population.py was unordered and unstructured, we applied aggregation to solve this problem. Through aggregation, code is modularized into shorter and in-relational contexts with other aggregated methods, thus, reduces complexity and increase readability and understanding. Additionally, creating a separate class for the different functions of the population decreases the magnitude of change amplification and eases imports of corresponding methods in other files. Everything that is related to the population module is in one place, separated by functionality. Further implementation can be easily added correspondingly.
Changes made
Aggregate design pattern on population.py
Restructured and reorganized classes and methods in population.py
Updated imports correspondingly across applicable files
Applying Aggregate Design Pattern to population.py Module
Introduction
I am a third-year computer science student. A part of the learning process for the Software Design course, we have to contribute to one of many given options of open source projects. For this particular project, we have to apply an aggregate design pattern to the chosen project publicly by making two pull requests.
Abstract
The code in population.py was unordered and unstructured, potentially losing unnecessary resources on reading and understanding the code. Mainly, some methods were given a class while others didn't have any. This is considered a bad practice in software design because it may lead to complexity, specifically low clarity on which parts of the code must be modified to make the improvement or future debugging. To solve this, I applied the aggregate design pattern by encapsulating the population class to emphasize the relation between the classes and methods such as:
Why aggregation?
As mentioned before, population.py was unordered and unstructured, we applied aggregation to solve this problem. Through aggregation, code is modularized into shorter and in-relational contexts with other aggregated methods, thus, reduces complexity and increase readability and understanding. Additionally, creating a separate class for the different functions of the population decreases the magnitude of change amplification and eases imports of corresponding methods in other files. Everything that is related to the population module is in one place, separated by functionality. Further implementation can be easily added correspondingly.
Changes made