Kamaropoulos / COVID19Py

A tiny Python package for easy access to up-to-date Coronavirus (COVID-19, SARS-CoV-2) cases data.
https://pypi.org/project/COVID19Py/
GNU General Public License v3.0
84 stars 57 forks source link

Applying structural design pattern (bridge) to code #107

Closed csais closed 3 years ago

csais commented 3 years ago

Applied bridge design pattern to main code file covid19.py. The main class (COVID19) uses two new formatter (1 and 2) classes to format the output of its data and make it easier to read for the user. The data is returned more neatly and vertically (rather than horizontally in a list). Dividers are also placed to show clear separation of data where needed (ex. between individual countries).
Formatter1 class is used to format the outputs of methods in COVID19 class that get data by country name, code and id. Formatter2 class is used to format output of methods that get total data (ex. getAll( ) method).

Should the formatting be changed, only the code in Formatter1 and 2 classes should be modified (and the main COVID19 class can be left as is).