I have implemented the singleton creational pattern within the COVID19 class. Once an instance of COVID19 is created it is stored in the class field __singleInstance. If the user tries to make another instance of COVID19 an exception is thrown. The creation of the initial instance can be done through either the constructor or the getInstance method. If the user attempts to make another instance of COVID19 through the getInstance method then no error is thrown and the original instance is passed to the user. The goal of this modification is to avoid potential bugs that could arise when multiple instances of the COVID19 class are created, that could be making multiple requests to the same covid19 backend concurrently within the same user program. The class should behave as it did before bar this change which I tested for during development. Just to note a future pull request which I should be making soon would conflict with this one as it involves extending the API beyond its current scope. I will leave a note there, but please do not merge both as it will not work.
I have implemented the singleton creational pattern within the
COVID19
class. Once an instance ofCOVID19
is created it is stored in the class field__singleInstance
. If the user tries to make another instance ofCOVID19
an exception is thrown. The creation of the initial instance can be done through either the constructor or thegetInstance
method. If the user attempts to make another instance ofCOVID19
through thegetInstance
method then no error is thrown and the original instance is passed to the user. The goal of this modification is to avoid potential bugs that could arise when multiple instances of theCOVID19
class are created, that could be making multiple requests to the same covid19 backend concurrently within the same user program. The class should behave as it did before bar this change which I tested for during development. Just to note a future pull request which I should be making soon would conflict with this one as it involves extending the API beyond its current scope. I will leave a note there, but please do not merge both as it will not work.