mardi 25 août 2020

Delegation Principle with Solid ISP

I'm trying to apply solid principles for upload and download docs usecase.

Here are the objects.

Question: I want to zip the file and save.

  1. I can create another interface for filesaving, but how should I pass the Document reference to filesaving interface from download method, any design pattern to be followed?

  2. I can use composition of FileSave interface and add the savetoZip() method in download(), but that violates single responsibility of download() method because it has nothing to do with transforming to zip.

  public class DocumentServiceImpl implements IDocumentService<Document> {

    private RestTemplate restTemplate;

    @Override
    public Document download() {
        return restTemplate.downloadDocument();
    }

    @Override
    public Document upload() {
        return restTemplate.uploadDocument;
    }
   }

    //ISP Principle
   public interface IDocumentService<T> extends IDocumentDownload<T>, IDocumentUpload<T>, 
     IDocumentProperty<T> {
   }

   public interface IDocumentDownload<T> {
      T download();
   }

Aucun commentaire:

Enregistrer un commentaire