mardi 25 octobre 2016

Looking for approach to design two classes and one interface

 public interface ISaveData
  {
     void DeleteFile(); // this is common method
     //void ChangeBucket(); I don't need this method in GoogleCloudSaveFile. Should I remove this from here
     // void AssignPermission(); // I don't need of this method in AzureSaveData. Should I remove this from here?
  }



  public class AzureSaveData : ISaveData
  {
     void ChangeBucket()
     {...}

     void DeleteFile()
    {...}
  }

  public class GoogleCloudSaveFile() : ISaveData
  {
     void AssignPermission()
     {...}
     void DeleteFile()
     {.....}
  }

I want to expose Interface to my presentation layer.

How can I design above three classes (2 classes and 1 interface) to expose all methods to my presentation layer. All methods means. - Delete()
- ChangeBucket()
- AssignPermission()

Please ask me if you need more explanation

Presentation layer could be like

void Main()
{
     ISaveData saveFiles = new GoogleCloudSaveFile(); // This is just example. I will inject this via Dependency Injection framework

    saveFiles.Delete();

}

ChangeBucket() and AssignPermission() are just example methods. I wanted to say, our child classes could have different methods like these two.

One solution is I can define these two methods in interface and can leave method body empty of one method but I don't think it will be good approach

Aucun commentaire:

Enregistrer un commentaire