jeudi 19 mars 2020

Is it a good practice that define a storage service as singleton pattern?

I am trying to implement a MyS3Serivce class in my project. In the class, it will provide createObject, deleteObject and getObject methods so other class can use it to do corresponding operation with AWS S3.

public MyS3Service () {

     private void createObject() {
         ...
     }

     private void deleteObject() {
         ...
     }

     private void getObject() {
         ...
     }
}

Now I am thinking if I should define it as a singleton? Or it should simply let other class to instantiate every time when they try to call it. I am not very good at design pattern. Sorry if it is a trivial question. Thanks in advance

Aucun commentaire:

Enregistrer un commentaire