ITU-BDSA2024-GROUP18 / Chirp

0 stars 0 forks source link

Singleton non thread safe #42

Closed Asger124 closed 14 hours ago

Asger124 commented 14 hours ago

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.