lundi 1 janvier 2018

Structure of classes

Happy New Year. I would like to know your opinion about this task. My task is to upload zip file from different sources like Local disc, GitHab, GoogleDrive. What source is input parameter.

It is not problem to implement it technicality. But what the best way for structure of classes for this task.

I can proposal this scheme:

public interface IStorage
{
    Task Download();
}


public class LocalDiscStorage : IStorage
{
    public async Task Download(){}
}

public class GithubStorage : IStorage
{
    public async Task Download(){}
}

public class StorageManager
{
    public IStorage CreateStorage(StorageType storageType)
    {

        if (storageType == StorageType.GitHub)
        {
            return new GithubStorage(destinationPath, repositoryName);
        }

        return new LocalDiscStorage(destinationPath, formFile);
    }
}

Сan anyone describe the disadvantages of this scheme ?

Aucun commentaire:

Enregistrer un commentaire