Junior — Middle+
Development of a unified access interface to various storage systems
livecode
Task condition
It is necessary to identify a common abstraction and design a unified interface that allows working with files, databases, and remote servers in the same way.
class Storage {
public:
virtual void Save(const std::string& location) = 0;
virtual void Read(const std::string& location) = 0;
virtual ~Storage() = default;
};
class FileManager : public Storage {
public:
void Save(const std::string& filePath) override;
void Read(const std::string& filePath) override;
};
class DBManager : public Storage {
public:
void Save(const std::string& url) override;
void Read(const std::string& url) override;
};
class ServerManager : public Storage {
public:
void Save(const std::string& url) override;
void Read(const std::string& url) override;
};
Describe what methods and types should be included in the abstraction, how to implement it, and how to ensure the ability to extend it for new storage types without modifying client code.