UserDB
Has Too Many Responsibilities ⟶ BackingStore
¶
Should the file format be the responsibility of something that is mainly an in-memory database?
Attention
There are bugfixes ongoing in the file IO scene. Please wait until they are in place to not unnecessarily conflict by ripping out code under modification.
(See Existing Files Are Overwritten and UserDB::read(): What If Done Twice?)
BackingStore
¶
Extract the bodies of UserDB::read()
and UserDB::write()
into
a new class BackingStore
. It is that class’s responsibility to
implement the details of binary and CSV files IO.
Class UserDB
gets passed a BackingStore
instance in its
read()
and write()
methods, as a replacement for a
filename
.
Like so,
class UserDB {
public:
void read(BackingStore&, /*...*/);
void write(BackingStore&, /*...*/);
};