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&, /*...*/);
};
../../../../../../../_images/backingstore-monolithic.png cluster_clean_code Backlog: What Needs To Change, Or We Will All Die cluster_clean_code_features Features cluster_clean_code_refactoring Refactoring cluster_clean_code_bugs Bugs clean_code_features_csv UserDB: Alternative Output Format - CSV clean_code_refactoring_backingstore_monolithic UserDB Has Too Many Responsibilities ⟶ BackingStore clean_code_refactoring_store_enum_switch UserDB::{read,write}(): bool, Really? clean_code_refactoring_backingstore_monolithic->clean_code_refactoring_store_enum_switch clean_code_bugs_overwrite_existing_files Existing Files Are Overwritten clean_code_refactoring_backingstore_monolithic->clean_code_bugs_overwrite_existing_files clean_code_bugs_overwrite_store_content_on_read UserDB::read(): What If Done Twice? clean_code_refactoring_backingstore_monolithic->clean_code_bugs_overwrite_store_content_on_read clean_code_refactoring_store_enum_switch->clean_code_features_csv