The implmentation is not thread safe - but that is not a requirement so far.
With the singleton pattern our database now has a private constructor that is parameterless.
This means that when we create an instance of our database its path is set through a private string, and to overwrite that string we now do it through the set_path method - found in CSVDatabase.cs.
This also means that i had to alter the tests that uses a 'test/path', to use the set_path method. I think it will make sense when you see the code. Additionally i have added a check for an empty string in src\Chirp.Cli line_31. We now check if arguments[--limit] is not an empty string, to prevent incorrect parsing.
For simplicity i adapted the simplest singleton pattern from:
https://csharpindepth.com/Articles/Singleton
The implmentation is not thread safe - but that is not a requirement so far. With the singleton pattern our database now has a private constructor that is parameterless. This means that when we create an instance of our database its path is set through a private string, and to overwrite that string we now do it through the set_path method - found in CSVDatabase.cs. This also means that i had to alter the tests that uses a 'test/path', to use the set_path method. I think it will make sense when you see the code. Additionally i have added a check for an empty string in src\Chirp.Cli line_31. We now check if arguments[--limit] is not an empty string, to prevent incorrect parsing.