Sobes.tech
Junior — Senior

Refactoring IOManager using the Single Responsibility Principle (SRP)

livecode

Task condition

It is necessary to refactor the monolithic class responsible for input-output, splitting it into several specialized components. Each of the new classes will perform operations only with one type of storage, thereby adhering to the single responsibility principle.

class UnifiedIOManager {
public:
    void SaveToFile(const std::string& path);
    void ReadFromFile(const std::string& path);

    void SaveToDB(const std::string& endpoint);
    void ReadFromDB(const std::string& endpoint);

    void SaveToServer(const std::string& endpoint);
    void ReadFromServer(const std::string& endpoint);
};

After splitting, separate classes such as FileStorage, DatabaseStorage, and ServerStorage should be created, each implementing only the relevant save and read methods.